-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvelite.config.ts
77 lines (71 loc) · 1.89 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
import rehypeSlug from "rehype-slug";
import { rehypePrettyCode } from "rehype-pretty-code";
import { defineCollection, defineConfig, s } from "velite";
import { rehypeCommand } from "~/lib/rehype-command";
import { rehypeFigureElement } from "~/lib/rehype-figure-element";
import { rehypePreElement } from "~/lib/rehype-pre-element";
import { rehypePrettyCodeOptions } from "~/lib/rehype-pretty-code";
import type { TechnologyName } from "~/lib/technologies";
const computedFields = <T extends { slug: string }>(data: T) => ({
...data,
slugAsParams: data.slug.split("/").slice(1).join("/"),
});
const posts = defineCollection({
name: "Posts",
pattern: "blog/**/*.mdx",
schema: s
.object({
title: s.string().max(99),
description: s.string().max(256).optional(),
date: s.isodate(),
cover: s.image(),
slug: s.path(),
toc: s.toc(),
content: s.mdx(),
})
.transform(computedFields),
});
const pages = defineCollection({
name: "Pages",
pattern: "pages/**/*.mdx",
schema: s
.object({
slug: s.path(),
content: s.mdx(),
})
.transform(computedFields),
});
const projects = defineCollection({
name: "Projects",
pattern: "projects/**/*.mdx",
schema: s
.object({
name: s.string().max(99),
description: s.string().max(999),
sourceCodeUrl: s.string().url(),
previewUrl: s.string().url().optional(),
isFeatured: s.boolean().optional().default(false),
technologies: s.custom<TechnologyName[]>(),
slug: s.path(),
toc: s.toc(),
content: s.mdx(),
})
.transform(computedFields),
});
export default defineConfig({
root: "src/content",
collections: {
posts,
pages,
projects,
},
mdx: {
rehypePlugins: [
rehypeSlug,
rehypePreElement,
[rehypePrettyCode, rehypePrettyCodeOptions],
rehypeFigureElement,
rehypeCommand,
],
},
});