-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvelite.config.ts
45 lines (42 loc) · 1.48 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
import { defineConfig, defineCollection, s } from 'velite'
import rehypeSlug from 'rehype-slug'
import rehypePrettyCode from 'rehype-pretty-code'
import rehypeAutoLinkHeadings from 'rehype-autolink-headings'
// Now we want to automate certain things
// like extraction of path from url
// /project/smoothy -> smoothy
const computedFields = <T extends { slug: string }>(data: T) => ({
...data,
slugAsParams: data.slug.split("/").slice(1).join("/"),
});
// defining a collection for projects
const projects = defineCollection({
name: 'projects',
pattern: "project/**/*.mdx",
schema: s.object({
slug: s.path(), // slug is the file path
title: s.string(), // title of the project
description: s.string(),
body: s.mdx(),
tags: s.array(s.string()),
github: s.string(),
deployment: s.string().optional(),
image: s.string(),
color: s.string(),
}).transform(computedFields),
});
export default defineConfig({
root: "content",
output: {
data: ".velite",
assets: "public/static/vellite", // static assets will be stored here
base: "/static/",
name: "[name]-[hash:6].[ext]",
clean: true,
},
collections: { projects },
mdx: {
rehypePlugins: [rehypeSlug, [rehypePrettyCode, { theme: 'one-dark-pro' }], [rehypeAutoLinkHeadings, { behavior: 'wrap', properties: { className: 'subheading-anchor' }, ariaLabel: "Link to section" }]],
remarkPlugins: [],
}
});