-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvelite.config.ts
More file actions
76 lines (75 loc) · 2.09 KB
/
velite.config.ts
File metadata and controls
76 lines (75 loc) · 2.09 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
import { defineConfig, s } from "velite";
import rehypeSlug from "rehype-slug";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import rehypePrettyCode from "rehype-pretty-code";
import remarkGfm from "remark-gfm";
export default defineConfig({
root: "content",
output: {
data: ".velite",
assets: "public/static",
base: "/static/",
name: "[name]-[hash:6].[ext]",
clean: true,
},
collections: {
posts: {
name: "Post",
pattern: "posts/**/*.mdx",
schema: s
.object({
title: s.string().max(200),
slug: s.slug("posts"),
date: s.isodate(),
lang: s.enum(["fr", "en"]),
translationSlug: s.string().optional(),
type: s.enum(["writeup", "tutorial", "journal", "watch", "incident"]),
category: s.enum([
"Web",
"Network",
"Privesc",
"OSINT",
"Forensics",
"Crypto",
"RE",
"Misc",
"App-Script",
"Scripting",
]),
difficulty: s.enum(["Easy", "Medium", "Hard"]),
tags: s.array(s.string()),
platform: s.string().optional(),
coverImage: s.string().optional(),
excerpt: s.string().max(500),
published: s.boolean().default(true),
raw: s.raw(),
body: s.mdx(),
})
.transform((data) => {
const { raw, coverImage, ...rest } = data;
const wordCount = raw.split(/\s+/).filter(Boolean).length;
const readingTime = Math.max(1, Math.ceil(wordCount / 200));
return {
...rest,
coverImage: coverImage || null,
permalink: `/blog/${data.slug}`,
readingTime,
};
}),
},
},
mdx: {
remarkPlugins: [remarkGfm],
rehypePlugins: [
rehypeSlug,
[rehypePrettyCode, { theme: "github-dark-default", keepBackground: false }],
[
rehypeAutolinkHeadings,
{
behavior: "wrap",
properties: { className: ["anchor"] },
},
],
],
},
});