fix: add remark/rehype plugins for math and syntax highlighting in MDX pipeline

This commit is contained in:
2026-06-01 20:33:11 -05:00
parent 8d17fe4307
commit 533c166f3b

View File

@@ -4,6 +4,10 @@ import matter from 'gray-matter'
import { compileMDX } from 'next-mdx-remote/rsc'
import { cache } from 'react'
import { useMDXComponents } from '@/mdx-components'
import remarkMath from 'remark-math'
import remarkGfm from 'remark-gfm'
import rehypeKatex from 'rehype-katex'
import rehypePrettyCode from 'rehype-pretty-code'
const postsDirectory = path.join(process.cwd(), 'content/posts')
@@ -59,7 +63,16 @@ export const getPost = async (slug: string): Promise<Post | null> => {
const { content: compiledContent } = await compileMDX({
source: content,
components,
options: { parseFrontmatter: true },
options: {
parseFrontmatter: true,
mdxOptions: {
remarkPlugins: [remarkMath, remarkGfm],
rehypePlugins: [
[rehypePrettyCode, { theme: 'github-dark' }],
rehypeKatex,
],
},
},
})
return {