-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvelite.config.ts
More file actions
93 lines (90 loc) · 2.43 KB
/
velite.config.ts
File metadata and controls
93 lines (90 loc) · 2.43 KB
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
import rehypePrettyCode from "rehype-pretty-code";
import rehypeSlug from "rehype-slug";
import { defineCollection, defineConfig, s } from "velite";
const kits = defineCollection({
name: "Kit",
pattern: "kits/**/*.mdx",
schema: s
.object({
title: s.string().max(99),
slug: s.slug("kits"),
status: s.enum(["experimental", "stable", "deprecated"]),
summary: s.string().max(500),
tags: s.array(s.string()),
lastUpdated: s.isodate(),
reference: s.object({
type: s.enum(["repo", "docs"]),
url: s.string().url(),
}),
category: s.enum(["sdk", "runtime", "testing", "docs", "ai", "other"]),
featured: s.boolean().optional(),
body: s.mdx(),
metadata: s.metadata(),
})
.transform((doc) => ({
...doc,
url: `/kits/${doc.slug}`,
order: (() => {
const path = (doc.metadata as { path?: string }).path || "";
const filename = path.split("/").pop() || "";
const match = filename.match(/^(\d+)\./);
return match ? parseInt(match[1], 10) : 999;
})(),
})),
});
const tools = defineCollection({
name: "Tool",
pattern: "tools/**/*.mdx",
schema: s
.object({
title: s.string().max(99),
slug: s.slug("tools"),
status: s.enum(["experimental", "stable", "deprecated"]),
summary: s.string().max(500),
tags: s.array(s.string()),
lastUpdated: s.isodate(),
reference: s.object({
type: s.enum(["repo", "docs"]),
url: s.string().url(),
}),
builtOn: s.array(s.string()),
featured: s.boolean().optional(),
body: s.mdx(),
metadata: s.metadata(),
})
.transform((doc) => {
return {
...doc,
url: `/tools/${doc.slug}`,
order: (() => {
const path = (doc.metadata as { path?: string }).path || "";
const filename = path.split("/").pop() || "";
const match = filename.match(/^(\d+)\./);
return match ? parseInt(match[1], 10) : 999;
})(),
};
}),
});
export default defineConfig({
root: "content",
output: {
data: ".velite",
assets: "public/static",
base: "/static/",
name: "[name]-[hash:6].[ext]",
clean: true,
},
collections: { kits, tools },
mdx: {
rehypePlugins: [
rehypeSlug,
[
rehypePrettyCode,
{
theme: "github-dark-dimmed",
keepBackground: true,
},
],
],
},
});