docs: bundle mermaid locally for offline diagram rendering

This commit is contained in:
kyasuda
2026-02-10 13:24:05 -08:00
committed by sudacode
parent b59e810e76
commit 628b63b165
3 changed files with 935 additions and 19 deletions

View File

@@ -1,16 +1,14 @@
import DefaultTheme from 'vitepress/theme';
import { useRoute } from 'vitepress';
import { nextTick, onMounted, watch } from 'vue';
import mermaid from 'mermaid';
import '@catppuccin/vitepress/theme/macchiato/mauve.css';
let mermaidLoader: Promise<any> | null = null;
async function getMermaid() {
if (!mermaidLoader) {
mermaidLoader = import(
/* @vite-ignore */ 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs'
).then((mod) => {
const mermaid = mod.default ?? mod;
mermaidLoader = Promise.resolve().then(() => {
mermaid.initialize({
startOnLoad: false,
securityLevel: 'loose',