import markdownIt from "markdown-it"; import readingTime from "eleventy-plugin-reading-time"; /** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */ export default async function (eleventyConfig) { eleventyConfig.addPassthroughCopy("assets"); eleventyConfig.addPassthroughCopy(".well-known"); eleventyConfig.addPassthroughCopy("**/*.jpg"); eleventyConfig.addPassthroughCopy("**/*.png"); eleventyConfig.addCollection("redirects", function (collectionApi) { let redirects = []; // get each post in our posts folder const nodes = collectionApi.getFilteredByGlob("**/*.md"); // iterate over all the nodes nodes.forEach((node) => // for each alias (node.data.aliases || []).forEach((alias) => // push target url and the old url redirects.push([ node.data.page.url, node.data.page.url.replace(/\/[^\/]*?(\..+)?$/, `/${alias}$1`), ]), ), ); return redirects; }); eleventyConfig.addCollection("posts", function (collection) { return collection.getFilteredByGlob("posts/**/*.md"); }); let options = { html: true, breaks: true, linkify: true, }; eleventyConfig.setLibrary("md", markdownIt(options)); eleventyConfig.addPlugin(readingTime); }