-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
102 lines (99 loc) · 2.87 KB
/
vite.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import { qwikCity } from "@builder.io/qwik-city/vite";
import { qwikVite } from "@builder.io/qwik/optimizer";
import { qwikSpeakInline } from "qwik-speak/inline";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { z } from "zod";
import mdxCollections from "./plugins/collections";
import { rewriteRoutes } from "./src/speak.routes";
export default defineConfig(async () => {
const { default: rehypePrettyCode } = await import("rehype-pretty-code");
const { visit } = await import("unist-util-visit");
return {
plugins: [
mdxCollections({
collections: [
{
name: "content",
glob: "./src/content/**/**/*.mdx",
schema: z.object({
date: z.coerce.date(),
tags: z.array(z.string()).default([]),
title: z.string(),
description: z.string(),
thumbnail: z.object({
alt: z.string(),
src: z.string(),
}),
permalink: z.string(),
lang: z.string(),
}),
},
],
}),
qwikCity({
rewriteRoutes,
mdxPlugins: {
rehypeSyntaxHighlight: false,
remarkGfm: true,
rehypeAutolinkHeadings: true,
},
mdx: {
rehypePlugins: [
() => (tree) => {
visit(tree, (node) => {
if (node?.type === "element" && node?.tagName === "pre") {
const [codeEl] = node.children;
if (codeEl.tagName !== "code") {
return;
}
node.__rawString__ = codeEl.children?.[0].value;
}
});
},
[
rehypePrettyCode,
{
theme: "poimandres",
},
],
() => (tree) => {
visit(tree, (node) => {
if (node?.type === "element" && node?.tagName === "figure") {
if (!("data-rehype-pretty-code-figure" in node.properties)) {
return;
}
const preElement = node.children.at(-1);
if (preElement.tagName !== "pre") {
return;
}
preElement.properties["__rawString__"] = node.__rawString__;
}
});
},
],
},
}),
qwikVite(),
qwikSpeakInline({
supportedLangs: ["en", "pt-BR"],
defaultLang: "en",
assetsPath: "i18n",
}),
tsconfigPaths(),
],
dev: {
headers: {
"Cache-Control": "public, max-age=0",
},
},
preview: {
headers: {
"Cache-Control": "public, max-age=600",
},
},
ssr: {
external: ["node:async_hooks"],
},
};
});