mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 19:05:06 +03:00
32 lines
881 B
TypeScript
32 lines
881 B
TypeScript
import { serialize } from 'next-mdx-remote/serialize'
|
|
import rehypeSlug from 'rehype-slug'
|
|
import remarkGfm from 'remark-gfm'
|
|
|
|
import { CodeHikeConfig, remarkCodeHike } from '@code-hike/mdx'
|
|
import codeHikeTheme from 'config/code-hike.theme.json' assert { type: 'json' }
|
|
|
|
export async function mdxSerialize(source: string) {
|
|
const codeHikeOptions: CodeHikeConfig = {
|
|
theme: codeHikeTheme,
|
|
lineNumbers: true,
|
|
showCopyButton: true,
|
|
skipLanguages: [],
|
|
autoImport: false,
|
|
}
|
|
|
|
const mdxSource: any = await serialize(source, {
|
|
scope: {
|
|
chCodeConfig: codeHikeOptions,
|
|
},
|
|
mdxOptions: {
|
|
remarkPlugins: [[remarkCodeHike, codeHikeOptions], 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
|
|
}
|