优化 Mermaid 渲染
This commit is contained in:
+40
-4
@@ -1,21 +1,42 @@
|
||||
// @ts-check
|
||||
import { defineConfig } from 'astro/config';
|
||||
import starlight from '@astrojs/starlight';
|
||||
import mdx from '@astrojs/mdx';
|
||||
import { unified } from '@astrojs/markdown-remark';
|
||||
import remarkMath from 'remark-math';
|
||||
import rehypeKatex from 'rehype-katex';
|
||||
import remarkMermaid from './src/plugins/remark-mermaid.mjs';
|
||||
import rehypeStaticMermaid, { mermaidThemes } from './src/plugins/rehype-mermaid.mjs';
|
||||
|
||||
export default defineConfig({
|
||||
site: 'https://docs.simba-robotics.com',
|
||||
redirects: { '/': '/zh-cn/' },
|
||||
markdown: {
|
||||
processor: unified({
|
||||
remarkPlugins: [remarkMath, remarkMermaid],
|
||||
rehypePlugins: [rehypeKatex],
|
||||
rehypePlugins: [rehypeKatex, [rehypeStaticMermaid, { themes: mermaidThemes }]],
|
||||
}),
|
||||
},
|
||||
vite: {
|
||||
build: {
|
||||
rolldownOptions: {
|
||||
onwarn(warning, warn) {
|
||||
// Astro 7.3 identifies propagated CSS by the virtual module's query.
|
||||
// Rolldown does not understand Astro's generated directive; keep the
|
||||
// module and its assets intact and ignore only this specific warning.
|
||||
if (
|
||||
warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
|
||||
warning.message.includes('"use astro:head-inject"') &&
|
||||
warning.message.includes('.mdx?astroPropagatedAssets')
|
||||
) return;
|
||||
warn(warning);
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
integrations: [starlight({
|
||||
title: 'ΣDOCS',
|
||||
disable404Route: true,
|
||||
description: 'Simba Robotics / 黑龙江大学 602 创新实验室的工程知识库与校内赛手册。',
|
||||
defaultLocale: 'zh-cn',
|
||||
locales: {
|
||||
@@ -23,8 +44,19 @@ export default defineConfig({
|
||||
en: { label: 'English', lang: 'en' },
|
||||
},
|
||||
favicon: '/simba/logo.svg',
|
||||
logo: { src: './public/simba/logo.svg', alt: 'Simba Robotics' },
|
||||
customCss: ['katex/dist/katex.min.css', './src/styles/custom.css'],
|
||||
logo: {
|
||||
light: './public/simba/logo-light.svg',
|
||||
dark: './public/simba/logo.svg',
|
||||
alt: 'Simba Robotics',
|
||||
},
|
||||
/*
|
||||
* `fonts.generated.css` carries the font stacks and the KaTeX faces. It is
|
||||
* produced by `scripts/generate-fonts.mjs` at predev/prebuild, and it must
|
||||
* stay last so its stack wins over Starlight's defaults. Note that KaTeX is
|
||||
* no longer imported from node_modules: doing so would make the bundler copy
|
||||
* the ~1 MB `KaTeX_*.woff2` set into `dist/_astro`.
|
||||
*/
|
||||
customCss: ['./src/styles/custom.css', './src/styles/fonts.generated.css'],
|
||||
components: { Head: './src/components/Head.astro' },
|
||||
expressiveCode: {
|
||||
styleOverrides: {
|
||||
@@ -46,5 +78,9 @@ export default defineConfig({
|
||||
{ label: '视觉算法 · VSAG', translations: { en: 'Vision & Algorithms' }, items: [{ autogenerate: { directory: 'vsag' } }] },
|
||||
{ label: '宣传筹划 · PRAM', translations: { en: 'Operations & Media' }, items: [{ autogenerate: { directory: 'pram' } }] },
|
||||
],
|
||||
})],
|
||||
}),
|
||||
// Keep SVG styles executable as style elements, instead of serializing
|
||||
// Astro's set:html directive into inert attributes during MDX optimization.
|
||||
mdx({ optimize: { ignoreElementNames: ['style'] } }),
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user