module.exports = function(eleventyConfig) { eleventyConfig.addPassthroughCopy("src/css"); // Copy css to site folder eleventyConfig.setServerOptions({ host: "0.0.0.0", port: 80 }); eleventyConfig.addWatchTarget("byTag"), (collection, tag) => { return collection.filter(item => item.data.tags && item.data.tags.includes(tag)); }; eleventyConfig.addFilter("filterTags", (tags) => { return (tags || []).filter(tag => !["recipe", "all", "nav"].includes(tag)); }); eleventyConfig.addCollection("recipesByTag", function(collectionApi) { const recipes = collectionApi.getFilteredByTag("recipe"); const tagMap = {}; recipes.forEach(recipe => { const customTags = (recipe.data.tags || []).filter(t => !["recipe", "all", "nav"].includes(t)); const tagsToUse = customTags.length > 0 ? customTags : ["other"]; tagsToUse.forEach(tag => { if (!tagMap[tag]) { tagMap[tag] = []; } tagMap[tag].push(recipe); }); }); return Object.keys(tagMap).sort().map(tag => ({ tagName: tag, recipes: tagMap[tag].sort((a, b) => (a.data.title || "").localeCompare(b.data.title || "")) })); }); eleventyConfig.addCollection("recipesByAuthor", function(collectionApi) { const recipes = collectionApi.getFilteredByTag("recipe"); const authorMap = {}; recipes.forEach(recipe => { const author = (recipe.data.author || "Unknown Cook").trim(); if (!authorMap[author]) { authorMap[author] = []; } authorMap[author].push(recipe); }); return Object.keys(authorMap).sort().map(author => ({ authorName: author, recipes: authorMap[author].sort((a, b) => (a.data.title || "").localeCompare(b.data.title || "")) })); }); return { dir: { input: "src", // Where your markdown files live output: "_site", // Where the built HTML goes layouts: "_layouts" // Where your HTML templates live } }; };