-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmdx.ts
35 lines (34 loc) · 959 Bytes
/
mdx.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { serialize } from 'next-mdx-remote/serialize';
import rehypeAutoLink from 'rehype-autolink-headings';
import rehypeSlug from 'rehype-slug';
import mdxPrims, { MdxPrismOptions } from 'mdx-prism-2';
import remarkCodeTitle from 'remark-code-titles';
import remarkUnwrapImages from 'remark-unwrap-images';
export function serializeMdx(source: string): ReturnType<typeof serialize> {
return serialize(source, {
mdxOptions: {
remarkPlugins: [remarkUnwrapImages, remarkCodeTitle] as never,
rehypePlugins: [
[
mdxPrims,
{
ignoreMissing: true,
lineHighlight: {
component: 'span',
},
} as MdxPrismOptions,
],
rehypeSlug,
[
rehypeAutoLink,
{
properties: {
className: 'copy-title-icon',
},
content: null,
},
],
] as never,
},
});
}