gil.ink/.eleventy.js

53 lines
1.3 KiB
JavaScript
Raw Normal View History

2025-04-30 02:44:05 -04:00
import { RenderPlugin, IdAttributePlugin } from "@11ty/eleventy";
2025-02-06 21:51:23 -05:00
import eleventyNavigationPlugin from "@11ty/eleventy-navigation";
import markdownIt from "markdown-it";
import markdownItFootnote from "markdown-it-footnote";
2025-02-19 03:03:13 -05:00
import { DateTime } from "luxon";
2025-02-06 21:51:23 -05:00
2025-02-18 15:12:10 -05:00
export default function (eleventyConfig) {
const MARKDOWN_OPTIONS = {
html: true,
breaks: true,
linkify: true,
typographer: true,
};
let md = markdownIt(MARKDOWN_OPTIONS)
2025-04-30 02:44:05 -04:00
.use(markdownItFootnote);
2025-02-06 21:51:23 -05:00
// Libraries
eleventyConfig.setLibrary("md", md);
// Plugins
2025-04-30 02:44:05 -04:00
eleventyConfig.addPlugin(RenderPlugin);
eleventyConfig.addPlugin(IdAttributePlugin);
2025-02-06 21:51:23 -05:00
eleventyConfig.addPlugin(eleventyNavigationPlugin);
2025-02-19 03:03:13 -05:00
// Filters
eleventyConfig.addFilter("formatDate", (dateObj) => {
2025-05-16 21:16:21 -04:00
return DateTime.fromJSDate(dateObj).toFormat("yyyy-MM-dd");
});
eleventyConfig.addFilter("formatDateRel", (dateObj) => {
return DateTime.fromJSDate(dateObj).toRelative();
2025-02-19 03:03:13 -05:00
});
2025-04-28 01:49:10 -04:00
eleventyConfig.addFilter("mdinline", (content) => {
return md.renderInline(content);
});
2025-02-19 03:03:13 -05:00
2025-02-06 21:51:23 -05:00
// Passthrough copies
2025-02-18 15:12:10 -05:00
["src/assets"].forEach((path) => {
eleventyConfig.addPassthroughCopy(path);
});
2025-04-30 02:44:05 -04:00
2025-02-06 21:51:23 -05:00
eleventyConfig.addWatchTarget("./src/assets/css");
return {
dir: {
2025-02-19 03:03:13 -05:00
input: "src",
output: "public",
includes: "_includes",
layouts: "_layouts",
2025-02-06 21:51:23 -05:00
},
};
}