diff --git a/_config/filters.js b/_config/filters.js index 1ecbb27..da669b8 100644 --- a/_config/filters.js +++ b/_config/filters.js @@ -34,35 +34,27 @@ module.exports = function (eleventyConfig, { TIME_ZONE, defaultLanguage }) { return filtered; }); - // takes a collection or all collections and returns only the tags no matched - // works with arrays and key-objects so may repurpose under different name - eleventyConfig.addFilter("exclude_tags", function (collection, ...tagsToExclude) { - if (!collection || typeof collection !== "object") { - console.warn("[exclude_tags] Invalid collection input:", collection); - return collection; + // takes all collections and returns only the tags not matched + // key-objects so may repurpose under different name + eleventyConfig.addFilter("exclude_collections", function (collections, ...keysToExclude) { + if (!collections || typeof collections !== "object") { + console.warn("[exclude_collections] Invalid collections input:", collections); + return collections; } - // handle both array and key-value object inputs - const items = Array.isArray(collection) ? collection : Object.values(collection); - - // filter out items where any of the tagsToExclude are in item.data.tags - const filtered = items.filter(item => { - const itemTags = item.data && item.data.tags ? item.data.tags : []; - return !tagsToExclude.some(tag => itemTags.includes(tag)); + const result = {}; + Object.keys(collections).forEach(key => { + if (!keysToExclude.includes(key)) { + result[key] = collections[key]; + } }); - // if input was a key-value object, reconstruct it - if (!Array.isArray(collection)) { - const result = {}; - Object.keys(collection).forEach(key => { - if (filtered.includes(collection[key])) { - result[key] = collection[key]; - } - }); - return result; + if (process.env.LOCALE_URL_DEBUG === "1" || process.env.LOCALE_URL_DEBUG === "true") { + console.warn("[excludeCollections] Excluded keys:", keysToExclude); + console.warn("[excludeCollections] Resulting keys:", Object.keys(result)); } - return filtered; + return result; }); const LOCALE_URL_DEBUG = process.env.LOCALE_URL_DEBUG === "1" || process.env.LOCALE_URL_DEBUG === "true";