twopn/eleventy.config.js
2026-02-18 15:23:53 -05:00

59 lines
1.8 KiB
JavaScript

import { pathToFileURL } from "node:url";
import { evaluate } from "@mdx-js/mdx";
import { renderToStaticMarkup } from "react-dom/server";
import * as runtime from "react/jsx-runtime";
import { feedPlugin } from "@11ty/eleventy-plugin-rss";
import { IdAttributePlugin } from "@11ty/eleventy";
import rehypePrism from "rehype-prism-plus";
export default function (eleventyConfig) {
eleventyConfig.setInputDirectory("site-src");
eleventyConfig.setLayoutsDirectory("layout");
eleventyConfig.setTemplateFormats(["mdx", "njk"]);
eleventyConfig.addExtension("mdx", {
compile: async (str, inputPath) => {
const { default: mdxContent } = await evaluate(str, {
...runtime,
baseUrl: pathToFileURL(inputPath),
rehypePlugins: [rehypePrism],
});
return async function (data) {
let res = await mdxContent(data);
return renderToStaticMarkup(res);
};
},
});
eleventyConfig.addPlugin(feedPlugin, {
type: "atom",
outputPath: "/feed.xml",
collection: {
name: "post",
limit: 100,
},
metadata: {
language: "en",
title: "terezi.pyrope.net",
subtitle: "mehbark posts about whatever",
base: "https://terezi.pyrope.net/",
author: {
name: "mehbark",
},
},
});
eleventyConfig.addPlugin(IdAttributePlugin);
eleventyConfig.setNunjucksEnvironmentOptions({
throwOnUndefined: true,
});
eleventyConfig.addPassthroughCopy("site-src/res");
eleventyConfig.addPassthroughCopy("site-src/*.png");
eleventyConfig.addPassthroughCopy("site-src/**/*.html");
eleventyConfig.addGlobalData("layout", "page.njk");
}