-
Notifications
You must be signed in to change notification settings - Fork 215
/
Copy pathvelite.config.js
65 lines (62 loc) · 1.42 KB
/
velite.config.js
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
import { defineConfig, s } from 'velite'
import GithubSlugger from "github-slugger"
import readingTime from "reading-time"
import rehypeAutolinkHeadings from "rehype-autolink-headings"
import rehypePrettyCode from "rehype-pretty-code"
import rehypeSlug from "rehype-slug"
import remarkGfm from "remark-gfm"
const codeOptions = {
theme: 'github-dark',
grid: false,
}
// Define the blog schema
const blog = s
.object({
title: s.string(),
publishedAt: s.isodate(),
updatedAt: s.isodate(),
description: s.string(),
image: s.image(),
isPublished: s.boolean().default(true),
author: s.string(),
tags: s.array(s.string()),
body: s.mdx(),
toc: s.toc(),
slug: s.string(),
})
.transform(data => {
return {
...data,
url: `/blogs/${data.slug}`,
readingTime: readingTime(data.body),
// toc: headings,
image: {
...data.image,
src: data.image.src.replace("/static", "/blogs"),
},
}
})
export default defineConfig({
root: 'content',
collections: {
blogs: {
name: 'Blog',
pattern: 'blogs/**/*.mdx',
schema: blog,
},
},
output: {
data: '.velite/generated',
assets: 'public/blogs',
clean: true,
},
// Add MDX plugins
mdx: {
remarkPlugins: [remarkGfm],
rehypePlugins: [
rehypeSlug,
[rehypeAutolinkHeadings, { behavior: "append" }],
[rehypePrettyCode, codeOptions]
]
}
})