import { rehypeCodeDefaultOptions } from "fumadocs-core/mdx-plugins"; import { fileGenerator, remarkDocGen, remarkInstall } from "fumadocs-docgen"; import { defineConfig, defineDocs } from "fumadocs-mdx/config"; import { transformerTwoslash } from "fumadocs-twoslash"; import rehypeKatex from "rehype-katex"; import remarkMath from "remark-math"; export const { docs, meta } = defineDocs({ dir: "./src/content/docs", }); export default defineConfig({ lastModifiedTime: "git", mdxOptions: { rehypeCodeOptions: { inline: "tailing-curly-colon", themes: { light: "catppuccin-latte", dark: "catppuccin-mocha", }, transformers: [ ...(rehypeCodeDefaultOptions.transformers ?? []), transformerTwoslash(), { name: "transformers:remove-notation-escape", code(hast) { for (const line of hast.children) { if (line.type !== "element") continue; const lastSpan = line.children.findLast( (v) => v.type === "element", ); const head = lastSpan?.children[0]; if (head?.type !== "text") return; head.value = head.value.replace(/\[\\!code/g, "[!code"); } }, }, ], }, remarkPlugins: [ remarkMath, [remarkInstall, { persist: { id: "package-manager" } }], [remarkDocGen, { generators: [fileGenerator()] }], ], rehypePlugins: (v) => [rehypeKatex, ...v], }, });