2026-09-23 14:51:36 -07:00
|
|
|
import { HtmlBasePlugin } from "@11ty/eleventy";
|
2026-09-10 20:06:29 +02:00
|
|
|
import { eleventyImageTransformPlugin } from "@11ty/eleventy-img";
|
2026-09-17 19:41:44 -07:00
|
|
|
import eleventyNavigationPlugin from "@11ty/eleventy-navigation";
|
2026-09-22 18:16:25 -07:00
|
|
|
|
|
|
|
|
import { attrs } from "@mdit/plugin-attrs";
|
2026-09-17 19:41:44 -07:00
|
|
|
import { markdownitLinkAttributes } from 'markdown-it-link-attributes';
|
2026-09-22 18:16:25 -07:00
|
|
|
import markdownitIdAttributes from "markdown-it-anchor";
|
|
|
|
|
|
2026-09-10 20:06:29 +02:00
|
|
|
import path from "node:path";
|
|
|
|
|
|
|
|
|
|
import pluginFilters from "./_config/filters.js";
|
|
|
|
|
|
|
|
|
|
export default async function (eleventyConfig) {
|
|
|
|
|
/* Markdown HTML attribute parsing */
|
|
|
|
|
eleventyConfig.amendLibrary("md", (mdLib) => mdLib.use(attrs));
|
|
|
|
|
|
2026-09-17 19:41:44 -07:00
|
|
|
/* Markdown apply target="_blank" to all external links */
|
2026-09-22 18:16:25 -07:00
|
|
|
eleventyConfig.amendLibrary("md", (mdLib) => mdLib.use(markdownitLinkAttributes, {
|
2026-09-17 19:41:44 -07:00
|
|
|
matcher(href) {
|
|
|
|
|
return href.match(/^https?:\/\//);
|
|
|
|
|
},
|
|
|
|
|
attrs: {
|
|
|
|
|
target: "_blank",
|
|
|
|
|
rel: "external",
|
|
|
|
|
},
|
2026-09-22 18:16:25 -07:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
/* Markdown apply ID attributes to headers */
|
|
|
|
|
eleventyConfig.amendLibrary("md", (mdLib) => mdLib.use(markdownitIdAttributes, {
|
|
|
|
|
level: [2, 3, 4],
|
|
|
|
|
tabIndex: false,
|
|
|
|
|
}));
|
2026-09-17 19:41:44 -07:00
|
|
|
|
2026-09-10 20:06:29 +02:00
|
|
|
/* Bundles */
|
|
|
|
|
/* CSS */
|
|
|
|
|
eleventyConfig.addBundle("css", {
|
|
|
|
|
toFileDirectory: "dist",
|
|
|
|
|
bundleHtmlContentFromSelector: "style",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* Javascript */
|
|
|
|
|
eleventyConfig.addBundle("js", {
|
|
|
|
|
toFileDirectory: "dist",
|
|
|
|
|
bundleHtmlContentFromSelector: "script",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* Passthroughs */
|
|
|
|
|
eleventyConfig.addPassthroughCopy("./favicon.ico");
|
|
|
|
|
|
2026-09-23 14:51:36 -07:00
|
|
|
/* HTML base */
|
|
|
|
|
eleventyConfig.addPlugin(HtmlBasePlugin);
|
|
|
|
|
|
2026-09-10 20:06:29 +02:00
|
|
|
/* Images */
|
|
|
|
|
eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
|
|
|
|
|
// output image formats
|
|
|
|
|
formats: ["auto"],
|
|
|
|
|
|
|
|
|
|
// output image widths
|
|
|
|
|
widths: ["auto"],
|
|
|
|
|
|
|
|
|
|
// optional, attributes assigned on <img> nodes override these values
|
|
|
|
|
htmlOptions: {
|
|
|
|
|
imgAttributes: {
|
|
|
|
|
loading: "lazy",
|
|
|
|
|
decoding: "async",
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-09-24 20:40:06 -07:00
|
|
|
filenameFormat: function (hash, src, width, format, options) {
|
|
|
|
|
var dirname = path.dirname(src);
|
|
|
|
|
dirname = dirname.split("/img/");
|
|
|
|
|
if (dirname.length > 1) return `${dirname[1]}-${path.basename(src)}`;
|
|
|
|
|
return path.basename(src);
|
|
|
|
|
},
|
2026-09-10 20:06:29 +02:00
|
|
|
});
|
|
|
|
|
|
2026-09-17 19:41:44 -07:00
|
|
|
eleventyConfig.addPlugin(eleventyNavigationPlugin);
|
|
|
|
|
|
2026-09-10 20:06:29 +02:00
|
|
|
/* All filters from _config/filters.js */
|
|
|
|
|
eleventyConfig.addPlugin(pluginFilters);
|
|
|
|
|
|
|
|
|
|
/* Shortcodes */
|
|
|
|
|
eleventyConfig.addShortcode("currentBuildDate", () => {
|
|
|
|
|
return new Date().toISOString();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* Watch when serving */
|
|
|
|
|
eleventyConfig.addWatchTarget("css");
|
2026-09-17 19:41:44 -07:00
|
|
|
eleventyConfig.addWatchTarget("js");
|
2026-09-10 20:06:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const config = {
|
|
|
|
|
dir: {
|
|
|
|
|
input: "src",
|
|
|
|
|
includes: "../_includes",
|
|
|
|
|
layouts: "../_includes/layouts",
|
|
|
|
|
data: "../_data",
|
|
|
|
|
},
|
|
|
|
|
markdownTemplateEngine: "njk",
|
|
|
|
|
htmlTemplateEngine: "njk",
|
|
|
|
|
templateFormats: ["html", "md", "njk"],
|
|
|
|
|
};
|