-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.config.ts
65 lines (60 loc) · 2.04 KB
/
astro.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
import { defineConfig } from "astro/config";
import mdx from "@astrojs/mdx";
import sitemap from "@astrojs/sitemap";
import GithubSlugger from "github-slugger";
import { visit } from "unist-util-visit";
// https://astro.build/config
export default defineConfig({
integrations: [mdx(), sitemap()],
markdown: {
rehypePlugins: [
() => (tree, file) => {
const slugger = new GithubSlugger();
visit(tree, "element", (elem) => {
if (["h2", "h3", "h4", "h5", "h6"].includes(elem.tagName)) {
// add a <a href=id></a>
if (elem.children[0]?.type !== "text") {
file.message(
"element does not have text child",
elem,
);
return;
}
const id = slugger.slug(elem.children[0].value);
if (!elem.properties) {
elem.properties = {};
}
elem.properties.id = id;
elem.children.unshift({
type: "element",
tagName: "a",
properties: {
href: `#${id}`,
},
children: [
{
type: "text",
value: "# ",
},
],
});
}
});
},
],
shikiConfig: {
experimentalThemes: {
light: "github-light",
dark: "github-dark",
},
},
},
site: "https://horo.services",
scopedStyleStrategy: "class",
build: {
assets: "static",
},
devToolbar: {
enabled: false,
},
});