-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
svelte.config.js
117 lines (113 loc) · 2.88 KB
/
svelte.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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import sectionize from "@hbsnow/rehype-sectionize";
import toc from "@jsdevtools/rehype-toc";
import adapter from "@sveltejs/adapter-static";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
import { mdsvex } from "mdsvex";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import rehypeRewrite from "rehype-rewrite";
import rehypeSlug from "rehype-slug";
export default {
kit: {
adapter: adapter(),
prerender: {
// Add new locales here
entries: ["/", "/en", "/fr"]
},
alias: {
$wiki: "wiki",
$l10n: "l10n"
}
},
extensions: [".svelte", ".md"],
preprocess: [
vitePreprocess(),
mdsvex({
extensions: [".md"],
rehypePlugins: [
rehypeSlug,
[
rehypeAutolinkHeadings,
{
behavior: "append",
content: {
type: "element",
tagName: "span",
properties: { className: "header-anchor-container pl-2" },
children: [
{
type: "element",
tagName: "i",
properties: {
className: "header-anchor icon i-fa6-solid-link has-text-link is-size-5"
}
}
]
}
}
],
[sectionize, { properties: { className: "" } }],
[
toc,
{
nav: false,
customizeTOC: (toc) => {
toc.properties.className = "menu-list";
return {
type: "element",
tagName: "div",
properties: {
className: "box is-hidden-mobile is-sticky sidebar table-of-contents"
},
children: [
{
type: "element",
tagName: "aside",
properties: { className: "menu" },
children: [
{
type: "element",
tagName: "p",
properties: { className: "menu-label" },
children: [{ type: "text", value: "Contents" }]
},
toc
]
}
]
};
}
}
],
[
rehypeRewrite,
{
rewrite: (node, index, parent) => {
if (
node.type == "element" &&
node.tagName == "ol" &&
(node.properties.className == "menu-list" ||
(node.properties.className && node.properties.className.includes("toc-level")))
) {
node.tagName = "ul";
}
if (node.type === "element" && node.tagName === "section") {
if (
node.properties &&
node.properties.dataHeadingRank &&
node.properties.dataHeadingRank === 1
) {
node.properties.className = "content";
} else {
parent.children.push(...node.children); // TODO: quick fix for heading padding bug, moves all child elements of the section in to the main section, and then ereases all section data (replacing them with divs), in order to try and keep the tree clean
node.children = [];
node.properties = {};
node.tagName = "div";
}
}
}
}
]
]
})
]
};