-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathastro.config.ts
More file actions
203 lines (201 loc) · 14 KB
/
astro.config.ts
File metadata and controls
203 lines (201 loc) · 14 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import { defineConfig, squooshImageService } from "astro/config";
import shikiji, { type RehypeShikijiOptions } from "rehype-shikiji";
import { transformerTwoslash } from "shikiji-twoslash";
import * as transformers from "shikiji-transformers";
import { nodeTypes } from "@mdx-js/mdx";
import rehypeImgFigure from "rehype-img-figure";
import rehypeSlug from "rehype-slug";
import rehypeRaw from "rehype-raw";
import { rehypeGithubAlerts, type IOptions } from "rehype-github-alerts";
import headings from "rehype-autolink-headings";
import vercel from "@astrojs/vercel/serverless";
import mdx from "@astrojs/mdx";
import solidJs from "@astrojs/solid-js";
import auth from "auth-astro";
import { fileURLToPath } from "url";
import { dirname, relative } from "path";
import { spawn } from "child_process";
let filename = "";
let code = "";
// https://astro.build/config
export default defineConfig({
output: "server",
adapter: vercel({
webAnalytics: {
enabled: true,
},
}),
devToolbar: {
enabled: false,
},
image: {
service: squooshImageService(),
},
markdown: {
syntaxHighlight: false,
},
integrations: [
{
name: "pagefind",
hooks: {
"astro:build:done": () => {
spawn("pnpm", ["run", "postbuild"], {
cwd: dirname(fileURLToPath(import.meta.url)),
stdio: "inherit",
});
},
},
},
mdx({
rehypePlugins: [
// @ts-expect-error - version mismatch
rehypeSlug,
// @ts-expect-error - version mismatch
rehypeImgFigure,
// @ts-expect-error - version mismatch
[rehypeRaw, { passThrough: nodeTypes }],
[headings, { behavior: "wrap" }],
[
// @ts-ignore
shikiji,
{
theme: "github-dark",
transformers: [
{
name: "bleh",
preprocess(_code) {
filename =
_code.match(
/\/\/ \[!filename (.*)\]/,
)?.[1] ?? "";
code = _code;
return _code.replace(
/\/\/ \[!filename (.*)\]\n?/,
"",
);
},
root(hast) {
if (!filename) return;
(hast.children[0] as any).children.unshift({
type: "element",
tagName: "div",
properties: {
className: ["code-header"],
},
children: [
{
type: "text",
value: filename,
},
{
type: "element",
tagName: "button",
properties: {
className: ["copy"],
"aria-label": "Copy Code",
"data-code":
this.meta.twoslash?.code.replaceAll(
/\s+\/\/ \[\!.+\]/g,
"",
) ||
code.replaceAll(
/\s+\/\/ \[\!.+\]/g,
"",
),
},
children: [
{
type: "element",
tagName: "svg",
properties: {
width: "16",
height: "16",
viewBox:
"0 0 16 16",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
},
children: [
{
type: "element",
tagName: "path",
properties: {
fillRule:
"evenodd",
clipRule:
"evenodd",
d: "M0 6.75C0 5.7835 0.783502 5 1.75 5H3.25C3.66421 5 4 5.33579 4 5.75C4 6.16421 3.66421 6.5 3.25 6.5H1.75C1.61193 6.5 1.5 6.61193 1.5 6.75V14.25C1.5 14.3881 1.61193 14.5 1.75 14.5H9.25C9.38807 14.5 9.5 14.3881 9.5 14.25V12.75C9.5 12.3358 9.83579 12 10.25 12C10.6642 12 11 12.3358 11 12.75V14.25C11 15.2165 10.2165 16 9.25 16H1.75C0.783502 16 0 15.2165 0 14.25V6.75Z",
fill: "currentColor",
},
},
{
type: "element",
tagName: "path",
properties: {
fillRule:
"evenodd",
clipRule:
"evenodd",
d: "M5 1.75C5 0.783502 5.7835 0 6.75 0H14.25C15.2165 0 16 0.783502 16 1.75V9.25C16 10.2165 15.2165 11 14.25 11H6.75C5.7835 11 5 10.2165 5 9.25V1.75ZM6.75 1.5C6.61193 1.5 6.5 1.61193 6.5 1.75V9.25C6.5 9.38807 6.61193 9.5 6.75 9.5H14.25C14.3881 9.5 14.5 9.38807 14.5 9.25V1.75C14.5 1.61193 14.3881 1.5 14.25 1.5H6.75Z",
fill: "currentColor",
},
},
],
},
],
},
],
});
filename = "";
return hast;
},
},
transformers.transformerNotationHighlight({}),
transformers.transformerNotationWordHighlight({}),
transformers.transformerNotationDiff({}),
transformerTwoslash({
langs: [
"typescript",
"javascript",
"jsx",
"tsx",
"ts",
],
twoslashOptions: {
compilerOptions: {
types: ["relagit", "node"],
},
},
}),
],
} satisfies RehypeShikijiOptions,
],
[
rehypeGithubAlerts,
{
alerts: [
{
keyword: "TIP",
icon: '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.5C5.637 1.5 4 3.19 4 5.25C4 6.234 4.424 6.875 4.984 7.554L5.198 7.807C5.421 8.071 5.668 8.363 5.871 8.655C6.155 9.066 6.408 9.551 6.492 10.145C6.51202 10.338 6.45649 10.5312 6.33707 10.6841C6.21766 10.837 6.04365 10.9376 5.85158 10.9649C5.65951 10.9922 5.46434 10.9441 5.30704 10.8305C5.14974 10.717 5.04256 10.5469 5.008 10.356C4.968 10.074 4.845 9.809 4.638 9.509C4.46879 9.27344 4.2879 9.04649 4.096 8.829C4.012 8.729 3.923 8.624 3.828 8.509C3.201 7.75 2.5 6.766 2.5 5.25C2.5 2.31 4.863 0 8 0C11.137 0 13.5 2.31 13.5 5.25C13.5 6.766 12.799 7.75 12.172 8.509C12.077 8.624 11.988 8.729 11.904 8.828C11.697 9.073 11.521 9.281 11.363 9.509C11.155 9.809 11.033 10.074 10.993 10.356C10.9791 10.4535 10.9461 10.5473 10.8959 10.6321C10.8457 10.7168 10.7794 10.7909 10.7006 10.85C10.6218 10.9091 10.5321 10.9521 10.4367 10.9765C10.3413 11.001 10.242 11.0064 10.1445 10.9925C10.047 10.9786 9.95318 10.9456 9.86843 10.8954C9.78367 10.8452 9.70962 10.7789 9.65052 10.7001C9.59142 10.6213 9.54841 10.5316 9.52396 10.4362C9.4995 10.3408 9.49408 10.2415 9.508 10.144C9.592 9.551 9.845 9.066 10.129 8.655C10.332 8.363 10.579 8.071 10.802 7.807C10.877 7.719 10.949 7.634 11.015 7.554C11.576 6.875 12 6.234 12 5.25C12 3.19 10.363 1.5 8 1.5ZM6 15.25C6 15.0511 6.07902 14.8603 6.21967 14.7197C6.36032 14.579 6.55109 14.5 6.75 14.5H9.25C9.44891 14.5 9.63968 14.579 9.78033 14.7197C9.92098 14.8603 10 15.0511 10 15.25C10 15.4489 9.92098 15.6397 9.78033 15.7803C9.63968 15.921 9.44891 16 9.25 16H6.75C6.55109 16 6.36032 15.921 6.21967 15.7803C6.07902 15.6397 6 15.4489 6 15.25ZM5.75 12C5.55109 12 5.36032 12.079 5.21967 12.2197C5.07902 12.3603 5 12.5511 5 12.75C5 12.9489 5.07902 13.1397 5.21967 13.2803C5.36032 13.421 5.55109 13.5 5.75 13.5H10.25C10.4489 13.5 10.6397 13.421 10.7803 13.2803C10.921 13.1397 11 12.9489 11 12.75C11 12.5511 10.921 12.3603 10.7803 12.2197C10.6397 12.079 10.4489 12 10.25 12H5.75Z" fill="currentColor"/></svg>',
title: "Tip",
},
{
keyword: "NOTE",
icon: '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_1189_748)"><path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.5C4.41015 1.5 1.5 4.41015 1.5 8C1.5 11.5899 4.41015 14.5 8 14.5C11.5899 14.5 14.5 11.5899 14.5 8C14.5 4.41015 11.5899 1.5 8 1.5ZM0 8C0 3.58172 3.58172 0 8 0C12.4183 0 16 3.58172 16 8C16 12.4183 12.4183 16 8 16C3.58172 16 0 12.4183 0 8ZM6.5 7.75C6.5 7.33579 6.83579 7 7.25 7H8.25C8.66421 7 9 7.33579 9 7.75V10.5H9.25C9.66421 10.5 10 10.8358 10 11.25C10 11.6642 9.66421 12 9.25 12H7.25C6.83579 12 6.5 11.6642 6.5 11.25C6.5 10.8358 6.83579 10.5 7.25 10.5H7.5V8.5H7.25C6.83579 8.5 6.5 8.16421 6.5 7.75ZM8 6C8.55229 6 9 5.55228 9 5C9 4.44772 8.55229 4 8 4C7.44772 4 7 4.44772 7 5C7 5.55228 7.44772 6 8 6Z" fill="currentColor"/></g><defs><clipPath id="clip0_1189_748"><rect width="16" height="16" fill="currentColor"/></clipPath></defs></svg>',
title: "Note",
},
{
keyword: "WARNING",
icon: '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M8.22056 1.75361C8.12638 1.57741 7.87377 1.57741 7.77959 1.75362L1.69795 13.1321C1.60894 13.2987 1.72961 13.5 1.91843 13.5H14.0817C14.2706 13.5 14.3912 13.2987 14.3022 13.1321L8.22056 1.75361ZM6.4567 1.04655C7.11596 -0.186903 8.8842 -0.186904 9.54346 1.04655L15.6251 12.4251C16.2482 13.5908 15.4035 15 14.0817 15H1.91843C0.596638 15 -0.248009 13.5908 0.375058 12.4251L6.4567 1.04655ZM9.00008 11C9.00008 11.5523 8.55237 12 8.00008 12C7.4478 12 7.00008 11.5523 7.00008 11C7.00008 10.4477 7.4478 10 8.00008 10C8.55237 10 9.00008 10.4477 9.00008 11ZM8.75008 5.75003C8.75008 5.33582 8.41429 5.00003 8.00008 5.00003C7.58587 5.00003 7.25008 5.33582 7.25008 5.75003V8.25003C7.25008 8.66424 7.58587 9.00003 8.00008 9.00003C8.41429 9.00003 8.75008 8.66424 8.75008 8.25003V5.75003Z" fill="currentColor"/></svg>',
title: "Warning",
},
],
} satisfies IOptions,
],
],
// remarkPlugins: [[remarkGfm, {}]], // throws errors on single backticks
}),
solidJs(),
auth(),
],
});