-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcontentlayer.config.ts
More file actions
37 lines (35 loc) · 1.01 KB
/
contentlayer.config.ts
File metadata and controls
37 lines (35 loc) · 1.01 KB
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
// contentlayer.config.ts
import { defineDocumentType, makeSource } from 'contentlayer2/source-files';
import remarkGfm from 'remark-gfm';
import { codeImport } from 'remark-code-import';
import rehypeSlug from 'rehype-slug';
import highlight from 'rehype-highlight';
export const Post = defineDocumentType(() => ({
name: 'Docs',
contentType: 'mdx',
filePathPattern: `**/*.mdx`,
markdown: { fileExtensions: ['mdx', 'md'] }, // Ensure it watches these files
fields: {
title: { type: 'string', required: true },
description: { type: 'string', required: false },
date: { type: 'date', required: false },
},
computedFields: {
url: {
type: 'string',
resolve: (post) => `/docs/${post._raw.flattenedPath}`,
},
slug: {
type: 'string',
resolve: (doc) => doc._raw.flattenedPath,
},
},
}));
export default makeSource({
contentDirPath: 'docs',
documentTypes: [Post],
mdx: {
remarkPlugins: [remarkGfm, codeImport],
rehypePlugins: [rehypeSlug, highlight],
},
});