-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvelite.config.ts
141 lines (134 loc) · 3.49 KB
/
velite.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import { defineConfig, defineCollection, s } from 'velite';
import rehypeSlug from 'rehype-slug';
import rehypePrettyCode, { LineElement } from 'rehype-pretty-code';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeKatex from 'rehype-katex';
import remarkMath from 'remark-math';
import remarkGfm from 'remark-gfm';
type ComputedFields = {
slug: string;
body: string;
};
const computedFields = <T extends ComputedFields>(data: T) => {
return {
...data,
slugAsParams: data.slug.split('/').slice(1).join('/'),
};
};
const blogs = defineCollection({
name: 'Post',
pattern: 'blog/**/*.mdx',
schema: s
.object({
slug: s.path(),
title: s.string().max(120),
description: s.string().max(1000),
date: s.isodate(),
published: s.boolean().default(true),
featured: s.boolean().default(false),
tags: s.array(s.string()),
series: s.string().optional(), // For multi-part blog posts
lastModified: s.isodate().optional(),
metadata: s.metadata(),
toc: s.toc(),
body: s.mdx(),
})
.transform(computedFields),
});
const projects = defineCollection({
name: 'Project',
pattern: 'projects/**/*.mdx',
schema: s
.object({
slug: s.path(),
title: s.string(),
description: s.string(),
date: s.isodate(),
status: s
.enum(['complete', 'in-progress', 'planned'])
.default('complete'),
tech: s.array(s.string()), // Technologies used
featured: s.boolean().default(false),
body: s.mdx(),
links: s.array(
s.object({
name: s.string(),
url: s.string().url(),
type: s.enum(['github', 'docs', 'demo', 'blog', 'other']),
}),
),
})
.transform(computedFields),
});
// Will add it to the page later on
const snippets = defineCollection({
name: 'Snippet',
pattern: 'snippets/**/*.mdx',
schema: s
.object({
slug: s.path(),
title: s.string(),
description: s.string(),
language: s.enum(['rust', 'cpp', 'python', 'typescript', 'other']),
tags: s.array(s.string()),
body: s.mdx(),
})
.transform(computedFields),
});
const work_experience = defineCollection({
name: 'WorkExperience',
pattern: 'work/**/*.mdx',
schema: s
.object({
slug: s.path(),
title: s.string(),
company: s.string(),
startDate: s.isodate(),
endDate: s.isodate().optional(),
description: s.string(),
skills: s.array(s.string()),
body: s.mdx(),
})
.transform(computedFields),
});
export default defineConfig({
root: 'src/content',
output: {
data: '.velite',
assets: 'public/static',
base: '/static/',
name: '[name]-[hash:8].[ext]',
clean: true,
},
collections: { blogs, projects, snippets, work_experience },
mdx: {
rehypePlugins: [
rehypeSlug,
rehypeKatex,
[
rehypePrettyCode,
{
theme: 'github-dark-default',
keepBackground: true,
onVisitLine(node: LineElement) {
// Prevent empty lines from collapsing
if (node.children.length === 0) {
node.children = [{ type: 'text', value: ' ' }];
}
},
},
],
[
rehypeAutolinkHeadings,
{
behavior: 'wrap',
properties: {
className: ['subheading-anchor'],
ariaLabel: 'Link to section',
},
},
],
],
remarkPlugins: [remarkMath, remarkGfm],
},
});