const images = require("./_data/images.json"); module.exports = function (eleventyConfig) { // Static assets shipped verbatim to the document root. eleventyConfig.addPassthroughCopy("assets"); eleventyConfig.addPassthroughCopy("robots.txt"); eleventyConfig.addPassthroughCopy("sitemap.xml"); // {% image "key", "alt text", 'loading="lazy" class="x"' %} // Emits an with width/height from _data/images.json (prevents CLS). eleventyConfig.addShortcode("image", function (key, alt, attrs = "") { const img = images[key]; if (!img) { throw new Error(`image shortcode: unknown key "${key}" (add it to _data/images.json)`); } const safeAlt = String(alt).replace(/"/g, """); const extra = attrs ? " " + attrs : ""; return `${safeAlt}`; }); // Current year, for the footer (replaces the deprecated document.write pattern). eleventyConfig.addShortcode("year", () => `${new Date().getFullYear()}`); // JSON-encode a value (for safely emitting strings into JSON-LD). eleventyConfig.addFilter("json", (v) => JSON.stringify(v)); return { dir: { input: ".", includes: "_includes", data: "_data", output: "_site" }, templateFormats: ["njk"], htmlTemplateEngine: "njk", markdownTemplateEngine: "njk", }; };