import { RenderPlugin, IdAttributePlugin } from "@11ty/eleventy"; import eleventyNavigationPlugin from "@11ty/eleventy-navigation"; import { feedPlugin } from "@11ty/eleventy-plugin-rss"; import markdownIt from "markdown-it"; import markdownItFootnote from "markdown-it-footnote"; import { DateTime } from "luxon"; export default function (eleventyConfig) { const MARKDOWN_OPTIONS = { html: true, breaks: true, linkify: true, typographer: true, }; let md = markdownIt(MARKDOWN_OPTIONS).use(markdownItFootnote); // Libraries eleventyConfig.setLibrary("md", md); // Plugins eleventyConfig.addPlugin(RenderPlugin); eleventyConfig.addPlugin(IdAttributePlugin); eleventyConfig.addPlugin(eleventyNavigationPlugin); eleventyConfig.addPlugin(feedPlugin, { type: "atom", // or "rss", "json" outputPath: "/feed.xml", collection: { name: "post", // iterate over `collections.posts` limit: 10, // 0 means no limit }, metadata: { language: "en", title: "Gil•INK", subtitle: "Gil's personal website", base: "https://gil.ink/", author: { name: "Gil Caley", email: "hello@gil.ink", }, }, }); // Filters eleventyConfig.addFilter("filterByCategory", function (posts, cat) { /* case matters, so let's lowercase the desired category, cat and we will lowercase our posts categories */ cat = cat.toLowerCase(); let result = posts.filter((p) => { let cats = p.data.categories.map((s) => s.toLowerCase()); return cats.includes(cat); }); return result; }); eleventyConfig.addFilter("formatDate", function (date, format) { return DateTime.fromJSDate(date).toFormat(format); }); eleventyConfig.addFilter("formatDateRel", function (date) { return DateTime.fromJSDate(date).toRelative(); }); eleventyConfig.addFilter("md", function (content = "") { return md.render(content); }); eleventyConfig.addFilter("mdInline", function (content = "") { return md.renderInline(content); }); // Passthrough copies ["src/assets"].forEach((path) => { eleventyConfig.addPassthroughCopy(path); }); // Watch targets eleventyConfig.addWatchTarget("./src/assets/css"); // Frontmatter parsing eleventyConfig.setFrontMatterParsingOptions({ excerpt: true }); // COLLECTIONS ////// Journal categories eleventyConfig.addCollection("categories", function (collectionApi) { let categories = new Set(); let posts = collectionApi.getFilteredByTag("post"); posts.forEach((p) => { let cats = p.data.categories; cats.forEach((c) => categories.add(c)); }); return Array.from(categories); }); return { dir: { input: "src", includes: "_includes", layouts: "_layouts", }, }; }