-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathastro.config.ts
More file actions
352 lines (338 loc) · 9.14 KB
/
Copy pathastro.config.ts
File metadata and controls
352 lines (338 loc) · 9.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
import cloudflare from "@astrojs/cloudflare";
import mdx from "@astrojs/mdx";
import react from "@astrojs/react";
import { satteri } from "@astrojs/markdown-satteri";
import starlight from "@astrojs/starlight";
import starlightLinksValidator from "starlight-links-validator";
import mermaid from "astro-mermaid";
import starlightLlmsTxt from "starlight-llms-txt";
import { loadEnv } from "vite";
import { readFile } from "node:fs/promises";
import satteriExternalLinks from "./src/plugins/satteri/external-links";
import satteriCallouts from "./src/plugins/satteri/callouts";
import { defineConfig } from "astro/config";
import type { HeadUserConfig } from "node_modules/@astrojs/starlight/schemas/head";
import type { Plugin } from "vite";
const { PUBLIC_ONETRUST_DOMAIN_ID, PUBLIC_GA_TAG_ID } = loadEnv(
process.env.NODE_ENV || "",
process.cwd(),
"",
);
const faviconBaseURL = "https://static.sumup.com";
function rawFonts(extensions: string[]): Plugin {
const pattern = new RegExp(
`\\.(${extensions.map((extension) => extension.replace(/^\./, "")).join("|")})$`,
);
return {
name: "raw-fonts",
enforce: "pre",
async load(id) {
if (!pattern.test(id)) {
return null;
}
const source = await readFile(id);
const bytes = Array.from(source);
return `export default new Uint8Array([${bytes.join(",")}]);`;
},
};
}
const head = (): HeadUserConfig => {
const head: HeadUserConfig = [
// font preload
{
tag: "link",
attrs: {
rel: "preload",
href: "https://static.sumup.com/fonts/sumup/sumup-narrow-latin-s.woff2",
as: "font",
type: "font/woff2",
crossorigin: true,
},
},
// icons
{
tag: "link",
attrs: {
rel: "icon",
type: "image/svg+xml",
href: new URL("/favicons/favicon.svg", faviconBaseURL).toString(),
},
},
{
tag: "link",
attrs: {
rel: "icon",
sizes: "96x96",
type: "image/png",
href: new URL("/favicons/favicon-96x96.png", faviconBaseURL).toString(),
},
},
{
tag: "link",
attrs: {
rel: "shortcut icon",
href: new URL("favicons/favicon.ico", faviconBaseURL).toString(),
},
},
{
tag: "link",
attrs: {
rel: "apple-touch-icon",
sizes: "180x180",
href: new URL(
"/favicons/apple-touch-icon.png",
faviconBaseURL,
).toString(),
},
},
{
tag: "link",
attrs: {
rel: "manifest",
href: new URL("/favicons/site.webmanifest", faviconBaseURL).toString(),
},
},
// Theme
{
tag: "link",
attrs: {
rel: "mask-icon",
href: new URL(
"/favicons/safari-pinned-tab.svg",
faviconBaseURL,
).toString(),
color: "#ffffff",
},
},
{
tag: "link",
attrs: {
rel: "shortcut icon",
href: new URL("/favicons/favicon.ico", faviconBaseURL).toString(),
},
},
{
tag: "meta",
attrs: {
name: "theme-color",
content: "#000000",
media: "(prefers-color-scheme: dark)",
},
},
{ tag: "meta", attrs: { name: "theme-color", content: "#fbfbf9" } },
{
tag: "script",
attrs: {
src: "https://static.sumup.com/legacy-browsers/check-support.js",
defer: true,
},
content: "",
},
{
tag: "link",
attrs: {
rel: "alternate",
type: "application/rss+xml",
title: "SumUp Developer Changelog RSS",
href: "/changelog/rss.xml",
},
},
{
tag: "meta",
attrs: {
name: "google-site-verification",
content: "0mA7KPaajXK9CtZgu7A9lLDHeTEZ_SiHdmXz2vDej7Y",
},
},
];
if (PUBLIC_ONETRUST_DOMAIN_ID) {
head.push({
tag: "script",
attrs: {
defer: true,
charset: "UTF-8",
src: "https://cdn-ukwest.onetrust.com/scripttemplates/otSDKStub.js",
"data-domain-script": PUBLIC_ONETRUST_DOMAIN_ID,
},
});
}
if (PUBLIC_GA_TAG_ID) {
head.push({
tag: "script",
attrs: {
src: `https://www.googletagmanager.com/gtag/js?id=${PUBLIC_GA_TAG_ID}`,
},
});
head.push({
tag: "script",
content: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${PUBLIC_GA_TAG_ID}');
`,
});
}
return head;
};
export default defineConfig({
adapter: cloudflare({
imageService: "compile",
prerenderEnvironment: "node",
}),
site: "https://developer.sumup.com",
markdown: {
processor: satteri({
features: {
directive: true,
gfm: true,
smartPunctuation: true,
},
mdastPlugins: [satteriCallouts],
hastPlugins: [satteriExternalLinks],
}),
},
experimental: {
contentIntellisense: true,
},
vite: {
plugins: [rawFonts([".woff2", ".woff", ".ttf", ".otf"])],
assetsInclude: ["**/*.wasm"], // Treat WASM files as assets (but not font files used by OG)
resolve: {
noExternal: ["@sumup-oss/circuit-ui", "@sumup-oss/illustrations"],
},
ssr: {
external: ["buffer", "path", "fs"].map((i) => `node:${i}`),
noExternal: ["workers-og"],
},
},
integrations: [
react(),
mermaid({
autoTheme: true,
}),
starlight({
plugins: [
...(process.env.CHECK_LINKS || false
? [
starlightLinksValidator({
components: [["Anchor", "url"]],
exclude: [
// API reference pages are generated through a dynamic route and
// don't map to static Starlight doc entries. Their rendered links
// are validated after the build by scripts/check-rendered-links.mjs.
"/api/**",
// Custom Astro page outside docs content collection.
"/contact",
// Custom help hub with dynamic sections rendered from Astro pages.
"/help",
"/help/**",
// Changelog routes are generated by src/pages/changelog/[...tag].astro.
"/changelog",
"/changelog/**",
],
errorOnInvalidHashes: true,
}),
]
: []),
starlightLlmsTxt({
// We use MDX with components extensively which starlightLlmsTxt doesn't
// handle well otherwise
rawContent: true,
}),
],
title: "SumUp Developer",
favicon: new URL("/favicons/favicon.svg", faviconBaseURL).toString(),
disable404Route: true,
tableOfContents: {
minHeadingLevel: 2,
maxHeadingLevel: 3,
},
sidebar: [
{
label: "Get Started",
items: [
{
label: "Home",
link: "/",
},
],
},
{
label: "In-person Payments",
items: [
{
autogenerate: { directory: "terminal-payments", collapsed: true },
},
],
},
{
label: "Online Payments",
items: [
{
autogenerate: { directory: "online-payments", collapsed: true },
},
],
},
{
label: "Developer Resources",
items: [
{
autogenerate: { directory: "tools", collapsed: true },
},
],
},
{
label: "Resources",
items: [
{
autogenerate: { directory: "resources", collapsed: true },
},
],
},
],
head: head(),
components: {
EditLink: "./src/overrides/EditLink.astro",
Footer: "./src/overrides/Footer.astro",
TableOfContents: "./src/overrides/TableOfContents.astro",
Head: "./src/overrides/Head.astro",
MobileMenuToggle: "./src/overrides/MobileMenuToggle.astro",
Hero: "./src/overrides/Hero.astro",
MarkdownContent: "./src/overrides/MarkdownContent.astro",
Sidebar: "./src/overrides/Sidebar.astro",
SiteTitle: "./src/overrides/SiteTitle.astro",
SocialIcons: "./src/overrides/SocialIcons.astro",
PageFrame: "./src/overrides/PageFrame.astro",
PageTitle: "./src/overrides/PageTitle.astro",
MobileTableOfContents: "./src/overrides/MobileTableOfContents.astro",
},
social: [
{
icon: "github",
label: "GitHub",
href: "https://github.com/sumup/sumup-developer",
},
],
editLink: {
baseUrl: "https://github.com/sumup/sumup-developer/edit/main/",
},
customCss: [
"@sumup-oss/circuit-ui/styles.css",
"./src/styles/theme-dark.css",
"./src/styles/theme-light.css",
"./src/styles/starlight-vars.css",
"./src/styles/utilities.css",
"./src/styles/callout.css",
],
pagination: false,
lastUpdated: true,
}),
mdx({
optimize: true,
}),
],
server: {
port: 3000,
},
});