-
Notifications
You must be signed in to change notification settings - Fork 1
/
astro.config.mjs
153 lines (146 loc) · 4.47 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import { defineConfig } from "astro/config";
import starlight from "@astrojs/starlight";
import rehypeExternalLinks from "rehype-external-links";
import remarkMath from "remark-math";
import rehypeKatex from "rehype-katex";
import { rehypeHeadingIds } from "@astrojs/markdown-remark";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import Icons from "unplugin-icons/vite";
import remarkWikiLink from "@braindb/remark-wiki-link";
import { bdb } from "./src/lib/braindb.mjs";
import { getCache } from "@beoe/cache";
import { rehypeMermaid } from "@beoe/rehype-mermaid";
import { rehypeGraphviz } from "@beoe/rehype-graphviz";
import { rehypeGnuplot } from "@beoe/rehype-gnuplot";
import { remarkDataview } from "./src/plugins/remarkDataview.mjs";
import url from "node:url";
const cache = await getCache();
await bdb.ready();
// https://astro.build/config
export default defineConfig({
site: "https://astro-digital-garden.stereobooster.com",
integrations: [
starlight({
title: "Astro Digital Garden",
social: {
github: "https://github.com/stereobooster/astro-digital-garden",
},
editLink: {
baseUrl:
"https://github.com/stereobooster/astro-digital-garden/edit/main/",
},
sidebar: [
{ label: "Introduction", link: "/" },
{
label: "Recipes",
// collapsed: true,
autogenerate: {
directory: "recipes",
},
},
],
// pagination doesn't make sense in the context of digital garden
pagination: false,
customCss: ["./src/styles/custom.css"],
components: {
PageFrame: "./src/components/PageFrame.astro",
TableOfContents: "./src/components/TableOfContents.astro",
Head: "./src/components/Head.astro",
// TODO: astro:page-load
// Sidebar: "./src/components/Sidebar.astro",
},
lastUpdated: true,
head: import.meta.env.PROD
? [
{
tag: "script",
attrs: {
src: "https://eu.umami.is/script.js",
"data-website-id": "2d34b0d4-893c-4348-a3e4-1f489300117c",
defer: true,
},
},
]
: undefined,
}),
],
markdown: {
remarkPlugins: [
[remarkDataview, { bdb }],
remarkMath,
[
remarkWikiLink,
{
linkTemplate: ({ slug, alias }) => {
const [slugWithoutAnchor, anchor] = slug.split("#");
const doc = bdb.documentsSync({ slug: slugWithoutAnchor })[0];
if (doc) {
return {
hName: "a",
hProperties: {
href: anchor ? `${doc.url()}#${anchor}` : doc.url(),
},
hChildren: [
{
type: "text",
value: alias == null ? doc.frontmatter().title : alias,
},
],
};
} else {
return {
hName: "span",
hProperties: {
class: "broken-link",
title: `Can't resolve link to ${slug}`,
},
hChildren: [{ type: "text", value: alias || slug }],
};
}
},
},
],
],
rehypePlugins: [
[
rehypeMermaid,
{ class: "not-content", cache, strategy: "img-class-dark-mode" },
],
[rehypeGraphviz, { class: "not-content", cache }],
[rehypeGnuplot, { class: "not-content", cache }],
rehypeHeadingIds,
[rehypeAutolinkHeadings, { behavior: "append" }],
[
rehypeExternalLinks,
{
target: "_blank",
rel: ["nofollow", "noopener"],
content: { type: "text", value: " ↗" }, // ⤴
contentProperties: { "aria-hidden": true, class: "no-select" },
// content: { type: "text", value: "" },
// contentProperties: (x) => {
// const hostname = new URL(x.properties.href).hostname;
// return {
// class: "external-icon",
// style: `--icon: url(https://external-content.duckduckgo.com/ip3/${hostname}.ico)`,
// };
// },
},
],
rehypeKatex,
],
},
vite: {
ssr: {
noExternal: ["katex"],
},
optimizeDeps: {
exclude: ["fsevents", "@node-rs", "@napi-rs"],
},
plugins: [
Icons({
compiler: "astro",
}),
],
},
});