Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 56 additions & 9 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { defineConfig } from 'astro/config';
import rehypeMermaid from 'rehype-mermaid';
import { rehypeShiki } from '@astrojs/markdown-remark';
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({
Expand All @@ -28,22 +29,68 @@ export const locales = Object.freeze({
'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: {
rehypePlugins: [
[rehypeMermaid, { dark: true, strategy: 'img-svg' }],
[rehypeShiki, { themes: { light: 'one-light', dark: 'one-dark-pro' } }]
],
remarkPlugins: [remarkCustomHeaderId],
remarkRehype: {
footnoteLabelTagName: 'span',
},
// 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: [
Expand Down
24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"translate": "node ./translate.mjs"
},
"devDependencies": {
"@astrojs/check": "^0.9.6",
"@astrojs/markdown-remark": "^6.3.10",
"@astrojs/mdx": "^4.3.13",
"@astrojs/sitemap": "^3.6.0",
"@astrojs/check": "^0.9.9",
"@astrojs/markdown-remark": "^7.2.1",
"@astrojs/mdx": "^7.0.2",
"@astrojs/sitemap": "^3.7.3",
"@astrolib/seo": "1.0.0-beta.8",
"@vitest/coverage-v8": "3.2.4",
"@vitest/coverage-v8": "4.1.9",
"any-ascii": "^0.3.2",
"arg": "^5.0.2",
"astro": "^5.16.5",
"astro": "^7.0.6",
"astro-i18n-aut": "^0.7.3",
"astro-icon": "^1.1.5",
"commander": "^13.0.0",
Expand All @@ -35,11 +35,11 @@
"openai": "^4.71.0",
"p-map": "^7.0.2",
"picocolors": "^1.1.1",
"playwright": "1.48.2",
"playwright": "1.61.1",
"rehype-mermaid": "^3.0.0",
"remark-custom-header-id": "^1.0.0",
"typescript": "^5.9.3",
"vitest": "3.2.4",
"vitest": "4.1.9",
"wrangler": "^3.114.17"
},
"pnpm": {
Expand All @@ -51,7 +51,6 @@
"overrides": {
"esbuild@<0.25.0": "^0.25.0",
"mermaid-isomorphic": "github:silverhand-io/mermaid-isomorphic#c081c30",
"vite@<6.4.1": "^6.4.1",
"glob@>=10.2.0 <10.5.0": "^10.5.0",
"diff@<8.0.3": "^8.0.3",
"undici@<6.23.0": "^6.23.0",
Expand All @@ -64,8 +63,11 @@
"axios@>=1.0.0 <=1.13.4": ">=1.13.5",
"minimatch@>=9.0.0 <9.0.6": ">=9.0.6"
},
"patchedDependencies": {
"playwright-core@1.48.2": "patches/playwright-core@1.48.2.patch"
"peerDependencyRules": {
"allowedVersions": {
"astro-i18n-aut>astro": "^7.0.0",
"@astrolib/seo>astro": "^7.0.0"
}
}
}
}
65 changes: 0 additions & 65 deletions patches/playwright-core@1.48.2.patch

This file was deleted.

Loading
Loading