import { DateTime } from "luxon"; export default function (eleventyConfig) { /* Filter out a given url from the collection */ eleventyConfig.addFilter("excludeFromCollection", function (collection=[], pageUrl=this.ctx.page.url) { return collection.filter(post => post.url !== pageUrl); }); /* Return only the collection items that match one or more tags */ eleventyConfig.addFilter("filterByTags", function(collection=[], ...requiredTags) { return collection.filter(post => { return requiredTags.flat().some(tag => post.data.tags.includes(tag)); }); }); /* Return the keys used in an object */ eleventyConfig.addFilter("getKeys", (target) => { return Object.keys(target); }); /* Return n elements from a list */ eleventyConfig.addFilter("head", (collection = [], n) => { if (!Array.isArray(collection) || collection.length === 0) { return []; } if (n < 0) { return collection.slice(n); } return collection.slice(0, n); }); /* For