fix: add remark/rehype plugins for math and syntax highlighting in MDX pipeline
This commit is contained in:
15
lib/posts.ts
15
lib/posts.ts
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user