-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcontentlayer.config.ts
134 lines (129 loc) · 3.66 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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 Project = defineDocumentType(() => ({
name: 'Project',
filePathPattern: 'projects/**/*.mdx',
contentType: 'mdx',
fields: {
name: {
type: 'string',
description: 'The name of the project',
required: true,
},
title: {
type: 'string',
description: 'The meta title of the project',
required: false,
},
description: {
type: 'string',
description: 'The description of the project',
required: true,
},
url: {
type: 'string',
description: "The link to the project's homepage",
required: false,
},
github: {
type: 'string',
description: "The url to the project's github page",
required: false,
},
icon: {
type: 'string',
description: 'The name of the icon to use',
required: true,
},
image: {
type: 'string',
description: 'Image for the project',
required: false,
},
featured: {
type: 'boolean',
description: 'Whether to feature this project',
required: false,
},
collab: {
type: 'boolean',
description: 'Whether this project is a collaboration',
required: true,
},
},
computedFields: {
slug: {
type: 'string',
resolve: (doc) => doc._raw.sourceFileName.replace(/\.mdx$/, ''),
},
},
}))
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: [Project, BlogPost, Pages],
mdx: {
remarkPlugins: remarkPlugins,
rehypePlugins: rehypePlugins,
} as MDXOptions,
})