-
-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathastro.config.mjs
More file actions
112 lines (109 loc) · 3.14 KB
/
Copy pathastro.config.mjs
File metadata and controls
112 lines (109 loc) · 3.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
import { defineConfig } from 'astro/config';
import rehypeMermaid from 'rehype-mermaid';
import { rehypeShiki, unified } from '@astrojs/markdown-remark';
import sitemap from '@astrojs/sitemap';
import mdx from '@astrojs/mdx';
import icon from "astro-icon";
import remarkCustomHeaderId from 'remark-custom-header-id';
import { i18n, filterSitemapByDefaultLocale } from "astro-i18n-aut/integration";
import rehypeCallouts from './src/utils/rehype-callouts.mjs';
export const defaultLocale = 'en';
export const locales = Object.freeze({
ar: 'ar',
de: 'de',
en: 'en',
es: 'es',
fr: 'fr',
it: 'it',
ko: 'ko',
ja: 'ja',
nl: 'nl',
'pt-br': 'pt-BR',
'pt-pt': 'pt-PT',
zh: 'zh-Hans',
// Astro doesn't maintain the case when generating file-based slugs, so we need to use the
// lowercase version of the locale code as the key.
// See: https://github.com/withastro/roadmap/pull/373#issuecomment-1332459000
// See: https://github.com/withastro/roadmap/discussions/516
'zh-hant': 'zh-Hant',
});
// Vite compiles MDX files in parallel, and rehype-mermaid opens a browser tab per
// file being rendered. Without a cap, hundreds of tabs open at once and exhaust
// system memory, so gate Mermaid rendering behind a small global concurrency limit.
const mermaidRenderLimit = 2;
let activeMermaidRenders = 0;
const pendingMermaidRenders = [];
const acquireMermaidSlot = () =>
new Promise((resolve) => {
if (activeMermaidRenders < mermaidRenderLimit) {
activeMermaidRenders += 1;
resolve();
} else {
pendingMermaidRenders.push(resolve);
}
});
const releaseMermaidSlot = () => {
const next = pendingMermaidRenders.shift();
if (next) {
next();
} else {
activeMermaidRenders -= 1;
}
};
const rehypeMermaidThrottled = (options) => {
const transform = rehypeMermaid(options);
return async (...args) => {
await acquireMermaidSlot();
try {
return await transform(...args);
} finally {
releaseMermaidSlot();
}
};
};
// https://astro.build/config
export default defineConfig({
site: 'https://auth.wiki',
build: {
format: 'file',
},
trailingSlash: 'never',
// Keep the pre-v7 HTML-aware whitespace handling; the v7 'jsx' default strips
// spaces between inline elements.
compressHTML: true,
markdown: {
// Astro 7 renders Markdown with its native Sätteri pipeline by default; keep
// using the unified (remark/rehype) pipeline since our plugins depend on it.
processor: unified({
remarkPlugins: [remarkCustomHeaderId],
rehypePlugins: [
rehypeCallouts,
[
rehypeMermaidThrottled,
{ dark: true, strategy: 'img-svg', launchOptions: { headless: true } },
],
[rehypeShiki, { themes: { light: 'one-light', dark: 'one-dark-pro' } }]
],
remarkRehype: {
footnoteLabelTagName: 'span',
},
}),
syntaxHighlight: false
},
integrations: [
i18n({
locales,
defaultLocale,
exclude: ['pages/**/*.ts']
}),
mdx(),
sitemap({
i18n: {
locales,
defaultLocale,
},
filter: filterSitemapByDefaultLocale({ defaultLocale }),
}),
icon()
]
});