Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit 4fcf170

Browse files
committed
chore: add table of content
1 parent b88aeda commit 4fcf170

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

contentlayer.config.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import {
33
defineDocumentType,
44
makeSource,
55
} from 'contentlayer/source-files';
6-
import remarkSlug from 'remark-slug';
7-
import remarkGfm from 'remark-gfm';
86
import remarkEmoji from 'remark-emoji';
9-
import { rehypeMdxCodeMeta } from './src/utils/rehype-code-meta';
7+
import remarkGfm from 'remark-gfm';
8+
import remarkSlug from 'remark-slug';
109
import siteConfig from './configs/site-config';
10+
import { getTableOfContents } from './src/utils/mdx-utils';
11+
import { rehypeMdxCodeMeta } from './src/utils/rehype-code-meta';
1112

1213
const computedFields: ComputedFields = {
1314
slug: {
@@ -36,6 +37,7 @@ const Blog = defineDocumentType(() => ({
3637
title: doc.title,
3738
description: doc.description,
3839
slug: `/${doc._raw.flattenedPath}`,
40+
headings: getTableOfContents(doc.body.raw),
3941
}),
4042
},
4143
},
@@ -61,6 +63,7 @@ const Guides = defineDocumentType(() => ({
6163
tags: doc.tags,
6264
author: doc.author,
6365
slug: `/${doc._raw.flattenedPath}`,
66+
headings: getTableOfContents(doc.body.raw),
6467
}),
6568
},
6669
},
@@ -88,6 +91,7 @@ const Doc = defineDocumentType(() => ({
8891
image: doc.image,
8992
version: doc.version,
9093
slug: `/${doc._raw.flattenedPath}`,
94+
headings: getTableOfContents(doc.body.raw),
9195
}),
9296
},
9397
},
@@ -109,6 +113,7 @@ const FAQ = defineDocumentType(() => ({
109113
title: doc.title,
110114
description: doc.description,
111115
slug: `/${doc._raw.flattenedPath}`,
116+
headings: getTableOfContents(doc.body.raw),
112117
}),
113118
},
114119
},

0 commit comments

Comments
 (0)