32 lines
969 B
JavaScript
32 lines
969 B
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";
|
|
|
|
export default function (eleventyConfig) {
|
|
eleventyConfig.addExtension("mdx", {
|
|
compile: async (str, inputPath) => {
|
|
const { default: mdxContent } = await evaluate(str, {
|
|
...runtime,
|
|
baseUrl: pathToFileURL(inputPath),
|
|
});
|
|
|
|
return async function (data) {
|
|
let res = await mdxContent(data);
|
|
return renderToStaticMarkup(res);
|
|
};
|
|
},
|
|
});
|
|
|
|
eleventyConfig.setNunjucksEnvironmentOptions({
|
|
throwOnUndefined: true,
|
|
});
|
|
|
|
eleventyConfig.addPassthroughCopy("site-src/res");
|
|
eleventyConfig.addPassthroughCopy("site-src/*.png");
|
|
|
|
eleventyConfig.setLayoutsDirectory("layout");
|
|
|
|
eleventyConfig.addGlobalData("layout", "page.njk");
|
|
}
|