-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontentlayer.config.ts
75 lines (71 loc) · 2.07 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { MDXOptions } from 'contentlayer/core'
import { defineDocumentType, makeSource } from 'contentlayer/source-files'
import { BlogAuthors } from './config/blog'
import { rehypePlugins, remarkPlugins } from './lib/mdx/plugins'
const BlogPost = defineDocumentType(() => ({
name: 'BlogPost',
filePathPattern: 'blog/**/*.mdx',
contentType: 'mdx',
fields: {
title: {
type: 'string',
description: 'The title of the blog post',
required: true,
},
createdAt: {
type: 'string',
description: 'The date of the blog post',
required: true,
},
modifiedAt: {
type: 'string',
description: 'The modified time of the blog post',
required: true,
},
summary: {
type: 'string',
description: 'The summary of the blog post',
required: true,
},
image: {
type: 'string',
description: 'Image for the blog post',
required: true,
},
authorId: {
type: 'string',
description: 'The author of the blog post',
required: true,
},
tags: { type: 'list', of: { type: 'string' }, default: [] },
},
computedFields: {
slug: {
type: 'string',
resolve: (doc) => doc._raw.sourceFileName.replace(/\.mdx$/, ''),
},
author: {
type: 'nested',
resolve: (doc) => BlogAuthors.find((author) => author.id === doc.authorId),
},
},
}))
const Pages = defineDocumentType(() => ({
name: 'Pages',
filePathPattern: 'pages/**/*.mdx',
contentType: 'mdx',
computedFields: {
slug: {
type: 'string',
resolve: (doc) => doc._raw.sourceFileName.replace(/\.mdx$/, ''),
},
},
}))
export default makeSource({
contentDirPath: 'contents',
documentTypes: [BlogPost, Pages],
mdx: {
remarkPlugins: remarkPlugins,
rehypePlugins: rehypePlugins,
} as MDXOptions,
})