import { MermaidMarkdown } from 'vitepress-plugin-mermaid'; import shiki from 'shiki'; export default { config: async (md) => { MermaidMarkdown(md); const fence = md.renderer.rules.fence.bind(md.renderer.rules); const highlighter = await shiki.getHighlighter({ theme: 'material-palenight' }); md.renderer.rules.fence = (tokens, index, options, env, slf) => { const token = tokens[index]; if (token.info.trim() === 'mermaid-example') { let code = highlighter.codeToHtml(token.content, { lang: 'mermaid' }); code = code.replace('#2e3440ff', 'transparent'); code = code.replace('#292D3E', 'transparent'); code = '
Code:
' + '
mermaid' + code + '
'; // return code; return `${code}
Render:
`; } return fence(tokens, index, options, env, slf); }; }, };