-
Notifications
You must be signed in to change notification settings - Fork 0
/
contentlayer.config.ts
112 lines (105 loc) · 3.16 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
// Styled after https://github.com/kfirfitousi/blog
import { defineDocumentType, type FieldDefs, makeSource } from 'contentlayer/source-files'
import { rehypePlugins, remarkPlugins } from './lib/mdx/mdx-plugins'
export const Post = defineDocumentType(() => ({
name: 'Post',
contentType: 'mdx',
filePathPattern: 'posts/**/*.mdx',
fields: {
title: { type: 'string', required: true },
slug: { type: 'string', required: true },
date: { type: 'date', required: true },
description: { type: 'string', required: true },
tags: { type: 'list', of: { type: 'string' } },
shareImage: { type: 'json' }, // TODO
},
computedFields: {
url: {
type: 'string',
resolve: post => `/blog/${post.slug}`,
},
},
}))
export const Job = defineDocumentType(() => ({
name: 'Job',
contentType: 'mdx',
filePathPattern: 'jobs/**/*.mdx',
fields: {
title: { type: 'string', required: true },
slug: { type: 'string', required: true },
fulltime: { type: 'boolean', required: true },
startDate: { type: 'date', required: true },
endDate: { type: 'date' },
current: { type: 'boolean', required: true },
jobUrl: { type: 'string' },
description: { type: 'string', required: true },
thumbnail: { type: 'json' }, // TODO
shareImage: { type: 'json' }, // TODO
bannerImage: { type: 'string' },
},
computedFields: {
url: {
type: 'string',
resolve: job => `/work/${job.slug}`,
},
},
}))
export const Project = defineDocumentType(() => ({
name: 'Project',
contentType: 'mdx',
filePathPattern: 'projects/**/*.mdx',
fields: {
title: { type: 'string', required: true },
slug: { type: 'string', required: true },
startDate: { type: 'date', required: true },
endDate: { type: 'date' },
current: { type: 'boolean', required: true },
projectUrl: { type: 'string' },
description: { type: 'string', required: true },
thumbnail: { type: 'json' }, // TODO
shareImage: { type: 'json' }, // TODO
bannerImage: { type: 'string' },
},
computedFields: {
url: {
type: 'string',
resolve: project => `/projects/${project.slug}`,
},
},
}))
const POST_COLLECTION_FIELDS: FieldDefs = {
title: { type: 'string', required: true },
slug: { type: 'string', required: true },
posts: { type: 'list', of: { type: 'string' }, required: true },
}
export const PostCollection = defineDocumentType(() => ({
name: 'PostCollection',
contentType: 'mdx',
filePathPattern: 'post-collections/**/*.mdx',
fields: POST_COLLECTION_FIELDS,
}))
export const PostSeries = defineDocumentType(() => ({
name: 'PostSeries',
contentType: 'mdx',
filePathPattern: 'series/**/*.mdx',
fields: {
...POST_COLLECTION_FIELDS,
description: { type: 'string', required: true },
bannerImage: { type: 'string', required: true },
bannerImageCredit: { type: 'markdown', required: true },
},
computedFields: {
url: {
type: 'string',
resolve: series => `/series/${series.slug}`,
},
},
}))
export default makeSource({
contentDirPath: './content',
documentTypes: [Post, PostCollection, PostSeries, Job, Project],
mdx: {
remarkPlugins,
rehypePlugins,
},
})