-
Notifications
You must be signed in to change notification settings - Fork 0
/
contentlayer.config.ts
43 lines (41 loc) · 1.15 KB
/
contentlayer.config.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
36
37
38
39
40
41
42
43
import { Post } from './src/schema/contentlayer/post';
import { makeSource } from 'contentlayer/source-files';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypePrettyCode from 'rehype-pretty-code';
import rehypeSlug from 'rehype-slug';
import remarkGfm from 'remark-gfm';
import remarkBreaks from 'remark-breaks';
const source = makeSource({
contentDirPath: './src/content',
documentTypes: [Post],
mdx: {
remarkPlugins: [
// 不要升级 remark-gfm 否则,contentlayer 会报错
remarkGfm,
remarkBreaks
],
rehypePlugins: [
rehypeSlug,
[
// @ts-expect-error https://github.com/rehype-pretty/rehype-pretty-code/issues/145
rehypePrettyCode,
{
// 代码主题类型 https://unpkg.com/browse/[email protected]/themes/
theme: 'one-dark-pro',
// 要应用自定义背景而不是从主题继承背景
keepBackground: false
}
],
[
rehypeAutolinkHeadings,
{
properties: {
// 锚点类名
className: ['anchor']
}
}
]
]
}
});
export default source;