-
Notifications
You must be signed in to change notification settings - Fork 2
/
velite.config.ts
70 lines (66 loc) · 1.44 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
import { defineCollection, defineConfig, s } from 'velite';
import rehypePrettyCode from 'rehype-pretty-code';
const allPosts = defineCollection({
name: 'Post',
pattern: 'blog/**/*.mdx',
schema: s
.object({
title: s.string(),
slug: s.string(),
description: s.string(),
publishedAt: s.isodate(),
language: s.string(),
content: s.mdx(),
})
.transform(data => ({
...data,
year: new Date(data.publishedAt).getFullYear(),
permalink: `/blog/${data.slug}`,
})),
});
const allProjects = defineCollection({
name: 'Project',
pattern: 'projects/**/*.mdx',
schema: s
.object({
title: s.string(),
slug: s.string(),
description: s.string(),
imageUrl: s.string(),
demoUrl: s.string(),
repoUrl: s.string(),
// repoName should be the same as your Github repo name in order to fetch data successfully.
repoName: s.string(),
language: s.string(),
content: s.mdx(),
})
.transform(data => ({
...data,
permalink: `/projects/${data.slug}`,
})),
});
const allPages = defineCollection({
name: 'Page',
pattern: 'pages/**/*.mdx',
schema: s
.object({
slug: s.string(),
language: s.string(),
content: s.mdx(),
})
.transform(data => ({
...data,
permalink: `/${data.slug}`,
})),
});
export default defineConfig({
collections: { allPosts, allProjects, allPages },
mdx: {
rehypePlugins: [
[rehypePrettyCode, {
keepBackground: false,
theme: 'github-dark',
}],
],
},
});