-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.config.mjs
115 lines (114 loc) · 3.23 KB
/
astro.config.mjs
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
import { defineConfig } from "astro/config";
import cloudflare from "@astrojs/cloudflare";
import react from "@astrojs/react";
import mdx from "@astrojs/mdx";
import sitemap from "@astrojs/sitemap";
import remarkEmoji from "remark-emoji";
import remarkHint from "remark-hint";
import remarkMath from "remark-math";
import rehypeExternalLinks from "rehype-external-links";
import rehypeFigure from "rehype-figure";
import rehypeKatex from "rehype-katex";
import rehypeSlug from "rehype-slug";
import rehypeToC from "rehype-toc";
export default defineConfig({
vite: {
resolve: {
preserveSymlinks: true,
},
ssr: {
external: ["node:buffer", "astro/container"],
},
},
markdown: {
gfm: true,
syntaxHighlight: "shiki",
shikiConfig: {
theme: "vitesse-light",
},
remarkPlugins: [remarkEmoji, remarkHint, remarkMath],
rehypePlugins: [
[
rehypeExternalLinks,
{
target: "_blank",
rel: ["nofollow", "noopener", "noreferrer"],
},
],
rehypeFigure,
rehypeKatex,
rehypeSlug,
[
rehypeToC,
{
customizeTOC: (toc) => {
if (toc.children[0].children.length === 0) {
return false;
}
const __ol2ul = function (tree) {
if (Array.isArray(tree)) {
return tree.map((t) => __ol2ul(t));
} else if (tree.tagName === "ol") {
return {
...tree,
tagName: "ul",
children: __ol2ul(tree.children),
};
} else if (tree.tagName === "li") {
return {
...tree,
children: __ol2ul(tree.children),
};
}
return tree;
};
toc.children = [
{
type: "element",
tagName: "details",
properties: {
className: "toc-details",
},
children: [
{
type: "element",
tagName: "summary",
properties: {
className: "toc-summary",
},
children: [
{
type: "element",
tagName: "span",
properties: {
className: "toc-summary-text",
id: "table-of-contents",
},
children: [
{
type: "text",
value: "Table of Contents",
},
],
},
],
},
...__ol2ul(toc.children),
],
},
];
toc.tagName = "section";
return toc;
},
},
],
],
},
integrations: [react(), mdx(), sitemap()],
output: "server",
adapter: cloudflare({
imageService: "passthrough",
}),
trailingSlash: "ignore",
site: `https://${process.env.ASTRO_SITE || "copernicus.local"}`,
});