-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontentlayer.config.ts
73 lines (70 loc) · 2.08 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
import { defineDocumentType, makeSource } from 'contentlayer/source-files';
import mdxOptions from './config/mdx';
import readingTime from 'reading-time';
export const Customize = defineDocumentType(() => ({
name: 'Customize',
contentType: 'data',
filePathPattern: 'config/**/*.yml',
fields: {
url: { type: 'string', required: true },
darkMode: { type: 'string', required: true },
home: { type: 'json' },
title: { type: 'string' },
description: { type: 'string' },
gridOfPosts: { type: 'json' },
mobile: { type: 'string' },
tablet: { type: 'string' },
desktop: { type: 'string' },
footerText: { type: 'string' },
archive: { type: 'json' },
postsSort: { type: 'string' },
postsOrder: { type: 'string' },
menu: { type: 'json', required: true },
name: { type: 'string' },
link: { type: 'string' },
img: { type: 'string' },
social: { type: 'json', required: true },
acitveArrowPaginationAfter: { type: 'number', default: 20 },
},
}));
export const Blog = defineDocumentType(() => ({
name: 'Blog',
contentType: 'mdx',
filePathPattern: 'blogs/**/*.mdx',
fields: {
title: { type: 'string', required: true },
publishedAt: { type: 'string', required: true },
description: { type: 'string', required: true },
cover: { type: 'string' },
tag: { type: 'json' },
author: { type: 'string', required: true },
tableOfContent: { type: 'string' },
},
computedFields: {
readingTime: {
type: 'json',
resolve: doc => readingTime(doc.body.raw),
},
slug: {
type: 'string',
resolve: doc => doc._raw.sourceFileName.replace(/\.mdx$/, ''),
},
path: {
type: 'string',
resolve: doc => doc._raw.sourceFileDir,
},
imageUrl: {
type: 'string',
resolve: doc =>
`/images/${
doc._raw.sourceFileDir
}/${doc._raw.sourceFileName.replace(/\.mdx$/, '')}/${doc.cover}`,
},
},
}));
export default makeSource({
contentDirPath: '.',
contentDirInclude: ['blogs', 'config'],
documentTypes: [Blog, Customize],
mdx: mdxOptions,
});