-
Notifications
You must be signed in to change notification settings - Fork 0
/
contentlayer.config.ts
99 lines (91 loc) · 2.82 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
import { defineDocumentType, makeSource } from 'contentlayer/source-files'
import { Marked } from 'marked'
import { markedHighlight } from 'marked-highlight';
import { getHighlighter } from 'shiki';
const marked = new Marked(
markedHighlight({
async: true,
async highlight(code, lang, _info) {
const highlighter = await getHighlighter({ theme: 'monokai' })
return highlighter.codeToHtml(code, lang)
}
})
)
const Tag = defineDocumentType(() => ({
name: 'Tag',
filePathPattern: 'tags/*.md',
fields: {
slug: { type: 'string' },
title: { type: 'string' },
icon: { type: 'string', required: false },
featured: { type: 'boolean', default: false, required: false },
},
}));
const Author = defineDocumentType(() => ({
name: 'Author',
filePathPattern: 'authors/*.md',
fields: {
slug: { type: 'string' },
name: { type: 'string' },
twitter: { type: 'string', required: false },
github: { type: 'string', required: false },
linkedin: { type: 'string', required: false },
medium: { type: 'string', required: false },
gpgKey: { type: 'string', required: false },
clubhouse: { type: 'string', required: false },
youtube: { type: 'string', required: false },
profilePicture: { type: 'string', required: true },
shortBio: { type: 'string', require: true },
},
}));
const Post = defineDocumentType(() => ({
name: 'Post',
filePathPattern: 'posts/*.md',
fields: {
publishedOn: { type: 'date', required: false },
title: { type: 'string' },
subTitle: { type: 'string', required: false },
canonicalUrl: { type: 'string', required: false },
featured: { type: 'boolean', default: false, required: false },
heroImg: {
type: 'string',
required: true,
},
slug: { type: 'string' },
tags: { type: 'list', of: { type: 'string' }, required: false },
relatedSlugs: { type: 'list', of: { type: 'string' }, required: false },
author: { type: 'string' },
},
computedFields: {
parsedMd: {
type: 'string',
resolve: (doc) => {
return marked.parse(doc.body.raw)
}
}
}
}));
const Trip = defineDocumentType(() => ({
name: 'Trip',
filePathPattern: 'trips/*.md',
fields: {
createdAt: { type: 'date' },
startCity: { type: 'string' },
startCountry: { type: 'string' },
endCity: { type: 'string' },
endCountry: { type: 'string' },
},
}));
const MicroPost = defineDocumentType(() => ({
name: 'MicroPost',
filePathPattern: 'microPosts/*.md',
fields: {
publishedOn: { type: 'date', required: false },
slug: { type: 'string' },
author: { type: 'string' },
// body: { type: 'markdown' },
},
}));
export default makeSource({
contentDirPath: 'content', documentTypes: [Post, MicroPost, Trip, Tag, Author], disableImportAliasWarning: true, contentDirExclude: ["pages"],
})