-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcontentlayer.config.ts
40 lines (38 loc) · 965 Bytes
/
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
import { defineDocumentType, makeSource } from "contentlayer2/source-files";
import rehypeSlug from "rehype-slug";
import remarkDefinitionList from "remark-definition-list";
import remarkGfm from "remark-gfm";
export const Page = defineDocumentType(() => ({
name: "Page",
filePathPattern: `**/*.md`,
contentType: "mdx",
fields: {
title: { type: "string", required: true },
},
computedFields: {
url: {
type: "string",
resolve: (doc) => {
return "/wiki/" + doc._raw.flattenedPath;
},
},
pathSegments: {
type: "json",
resolve: (doc) => ("/wiki/" + doc._raw.flattenedPath).split("/"),
},
path: {
type: "string",
resolve: (doc) => {
return doc._raw.flattenedPath;
},
},
},
}));
export default makeSource({
contentDirPath: "wiki",
documentTypes: [Page],
mdx: {
remarkPlugins: [remarkGfm, remarkDefinitionList],
rehypePlugins: [rehypeSlug],
},
});