vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.15k stars 2.12k forks source link

How to use markdown-it-mermaid? #269

Closed qdbest closed 3 years ago

qdbest commented 3 years ago
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
sampullman commented 3 years ago

I couldn't get the markdown-it plugin to work, so I did a hacky workaround by registering a custom Vue component that loads mermaid and replaces the input diagram description with a generated SVG. In the end, we found that mermaid is pretty bulky (800kB+), so it made more sense to pre-generate images with mermaid-cli. Our setup is:

"scripts": {
    "dev": "vitepress dev docs",
    "build": "vitepress build docs",
    "mermaid": "glob-run mmdc -i mermaid/\\*.mmd -o docs/img/\\*.svg"
},
kiaking commented 3 years ago

Please post questions to the discord 👍 I think any markdown-it plugin can be registered through markdown config, though if something is not working, then please open another issue with reproduction code 🙌