Files
district-dharma/eleventy.config.js
T

87 lines
2.0 KiB
JavaScript
Raw Normal View History

2026-05-18 23:20:54 +02:00
import { eleventyImageTransformPlugin } from "@11ty/eleventy-img";
2026-09-15 18:09:41 -07:00
import { attrs } from "@mdit/plugin-attrs";
import { markdownitLinkAttributes } from 'markdown-it-link-attributes';
2026-08-27 13:30:29 -07:00
import path from "node:path";
2026-05-18 23:20:54 +02:00
import pluginFilters from "./_config/filters.js";
export default async function (eleventyConfig) {
/* Markdown HTML attribute parsing */
eleventyConfig.amendLibrary("md", (mdLib) => mdLib.use(attrs));
2026-09-15 18:09:41 -07:00
/* Markdown apply target="_blank" to all external links */
const milaOptions = {
matcher(href) {
return href.match(/^https?:\/\//);
},
attrs: {
target: "_blank",
rel: "external",
},
};
eleventyConfig.amendLibrary("md", (mdLib) => mdLib.use(markdownitLinkAttributes, milaOptions));
2026-05-18 23:20:54 +02:00
/* Bundles */
/* CSS */
eleventyConfig.addBundle("css", {
toFileDirectory: "dist",
bundleHtmlContentFromSelector: "style",
});
/* Javascript */
eleventyConfig.addBundle("js", {
toFileDirectory: "dist",
bundleHtmlContentFromSelector: "script",
});
/* Passthroughs */
2026-09-12 18:21:23 -07:00
eleventyConfig
.addPassthroughCopy("favicon.ico")
.addPassthroughCopy("robots.txt");
2026-05-18 23:20:54 +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-08-27 13:27:51 -07:00
filenameFormat: function (hash, src, width, format, options) {
return path.basename(src);
},
2026-05-18 23:20:54 +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");
}
export const config = {
dir: {
input: "src",
includes: "../_includes",
layouts: "../_includes/layouts",
data: "../_data",
},
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
templateFormats: ["html", "md", "njk"],
};