Files
supabase/apps/www/lib/mdx/mdxSerialize.ts
T

18 lines
474 B
TypeScript

import { serialize } from 'next-mdx-remote/serialize'
import rehypeSlug from 'rehype-slug'
import remarkGfm from 'remark-gfm'
export async function mdxSerialize(source: string) {
const mdxSource: any = await serialize(source, {
mdxOptions: {
remarkPlugins: [remarkGfm],
rehypePlugins: [
// @ts-ignore
rehypeSlug, // add IDs to any h1-h6 tag that doesn't have one, using a slug made from its text
],
},
})
return mdxSource
}