-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontentlayer.config.ts
116 lines (111 loc) · 3.36 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 rehypePrism from 'rehype-prism-plus'
import rehypeStringify from 'rehype-stringify'
import remarkFrontmatter from 'remark-frontmatter'
import remarkParse from 'remark-parse'
import wikiLinkPlugin from 'remark-wiki-link'
import remark2rehype from 'remark-rehype'
import remarkGfm from 'remark-gfm'
export const Post = defineDocumentType(() => ({
name: 'Post',
filePathPattern: 'posts/*.md',
fields: {
title: { type: 'string', required: true },
date: { type: 'string', required: true },
tags: { type: 'string', required: false },
excerpt: { type: 'string', required: false },
series: { type: 'string', required: false },
slug: { type: 'string', required: false },
draft: { type: 'boolean', required: false, default: false },
metaDescription: { type: 'string', required: false },
},
computedFields: {
url: {
type: 'string',
resolve: (post) => `/${post._raw.flattenedPath}`,
},
computedSlug: {
type: 'string',
resolve: (post) =>
post.slug || post._raw.flattenedPath.replace('posts/', ''),
},
},
}))
export const Note = defineDocumentType(() => ({
name: 'Note',
filePathPattern: 'notes/*.md',
fields: {
title: { type: 'string', required: true },
headline: { type: 'string', required: false },
link: { type: 'string', required: false },
layout: { type: 'string', required: false },
date: { type: 'string', required: true },
},
computedFields: {
url: {
type: 'string',
resolve: (note) => `/${note._raw.flattenedPath}`,
},
slug: {
type: 'string',
resolve: (note) => note._raw.flattenedPath.replace('notes/', ''),
},
},
}))
export const Seed = defineDocumentType(() => ({
name: 'Seed',
filePathPattern: 'garden/*.md',
fields: {
title: { type: 'string', required: true },
wip: { type: 'boolean', required: false },
createdAt: { type: 'string', required: true },
updatedAt: { type: 'string', required: true },
excerpt: { type: 'string', required: false },
},
computedFields: {
slug: {
type: 'string',
resolve: (seed) => seed._raw.flattenedPath.replace('garden/', ''),
},
url: {
type: 'string',
resolve: (seed) => `/${seed._raw.flattenedPath}`,
},
},
}))
export const LibraryArticle = defineDocumentType(() => ({
name: 'LibraryArticle',
filePathPattern: 'library/articles/*.md',
fields: {
link: { type: 'string', requierd: true },
title: { type: 'string', required: true },
createdAt: { type: 'string', required: true },
tags: { type: 'string', required: false },
},
computedFields: {
url: {
type: 'string',
resolve: (article) => `/${article._raw.flattenedPath}`,
},
computedSlug: {
type: 'string',
resolve: (article) =>
article._raw.flattenedPath.replace('library/articles/', ''),
},
},
}))
export default makeSource({
contentDirPath: 'content',
documentTypes: [Post, Note, Seed, LibraryArticle],
markdown: (builder) => {
builder.use(remarkFrontmatter)
builder.use(remarkParse as any)
builder.use(remarkGfm)
builder.use(remark2rehype)
builder.use(rehypeStringify as any)
builder.use(rehypePrism)
builder.use(wikiLinkPlugin, {
hrefTemplate: (permalink: string) => `/digital-garden/${permalink}`,
})
},
})