-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontentlayer.config.ts
116 lines (109 loc) · 2.69 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
import { defineDocumentType, makeSource } from 'contentlayer/source-files'
import rehypeAutolinkHeadings from 'rehype-autolink-headings'
import rehypeCodeTitles from 'rehype-code-titles'
import rehypePrism from 'rehype-prism-plus'
import rehypeSlug from 'rehype-slug'
import remarkGfm from 'remark-gfm'
const BlogEN = defineDocumentType(() => ({
name: 'BlogEnUS',
filePathPattern: 'blog/en-US/*.md',
fields: {
title: { type: 'string', required: true },
date: { type: 'string', required: true },
description: { type: 'string', required: true },
image: { type: 'string', required: true },
tags: {
type: 'list',
of: { type: 'string' },
required: true
}
},
computedFields: {
url: {
type: 'string',
resolve: (enUS) => `/blog/${enUS._raw.flattenedPath}`
}
}
}))
const BlogBR = defineDocumentType(() => ({
name: 'BlogPtBR',
filePathPattern: 'blog/pt-BR/*.md',
fields: {
title: { type: 'string', required: true },
date: { type: 'string', required: true },
description: { type: 'string', required: true },
image: { type: 'string', required: true },
tags: {
type: 'list',
of: { type: 'string' },
required: true
}
},
computedFields: {
url: {
type: 'string',
resolve: (ptBR) => `/blog/${ptBR._raw.flattenedPath}`
}
}
}))
const TipsEN = defineDocumentType(() => ({
name: 'TipsEnUS',
filePathPattern: 'tips/en-US/*.md',
fields: {
title: { type: 'string', required: true },
description: { type: 'string', required: true },
image: { type: 'string', required: true },
tags: {
type: 'list',
of: { type: 'string' },
required: true
}
},
computedFields: {
url: {
type: 'string',
resolve: (enUS) => `/tips/${enUS._raw.flattenedPath}`
}
}
}))
const TipsBR = defineDocumentType(() => ({
name: 'TipsPtBR',
filePathPattern: 'tips/pt-BR/*.md',
fields: {
title: { type: 'string', required: true },
description: { type: 'string', required: true },
image: { type: 'string', required: true },
tags: {
type: 'list',
of: { type: 'string' },
required: true
}
},
computedFields: {
url: {
type: 'string',
resolve: (ptBR) => `/tips/${ptBR._raw.flattenedPath}`
}
}
}))
const contentLayerConfig = makeSource({
contentDirPath: 'content',
documentTypes: [BlogEN, BlogBR, TipsBR, TipsEN],
mdx: {
remarkPlugins: [remarkGfm],
rehypePlugins: [
rehypeSlug,
rehypeCodeTitles,
rehypePrism,
[
rehypeAutolinkHeadings,
{
properties: {
className: ['anchor']
}
}
]
]
}
})
export default contentLayerConfig