feat(mdx-preview): add support for math rendering with KaTeX

This commit is contained in:
cfngc4594 2025-02-25 15:09:44 +08:00
parent 0c2b3c897f
commit 2e33dea853

View File

@ -1,8 +1,11 @@
"use client"; "use client";
import "@/style/mdx.css"; import "@/style/mdx.css";
import "katex/dist/katex.min.css";
import remarkGfm from "remark-gfm"; import remarkGfm from "remark-gfm";
import remarkMath from "remark-math";
import rehypeSlug from "rehype-slug"; import rehypeSlug from "rehype-slug";
import rehypeKatex from "rehype-katex";
import { useTheme } from "next-themes"; import { useTheme } from "next-themes";
import rehypePretty from "rehype-pretty-code"; import rehypePretty from "rehype-pretty-code";
import { Skeleton } from "@/components/ui/skeleton"; import { Skeleton } from "@/components/ui/skeleton";
@ -55,8 +58,9 @@ export default function MdxPreview({ source }: MdxPreviewProps) {
keepBackground: false, keepBackground: false,
}, },
], ],
rehypeKatex,
], ],
remarkPlugins: [remarkGfm], remarkPlugins: [remarkGfm, remarkMath],
}, },
}); });
setMdxSource(mdxSource); setMdxSource(mdxSource);