MermaidJS
09-Oct-2023
Mermaid
This blog theme supports Mermaid JS using the following invocation/integration.
Client side render
HTML pre tag
A pre tag with a class mermaid will have its content processed by mermaid.
However, do note that the file format is MDX (MarkdownJSX), so things to note:
- Set the
classattribute usingclassName(JSX) - Preserve mermaid code formatting (indent) by using JSX
{}syntax.
See the MDX code below
<pre className="mermaid">
{
`graph TD
A[Client] --> B[Load Balancer]
B --> C[Server1]
B --> D[Server2]
`
}
</pre>Will transform into:
Mermaid React component
A specific Mermaid component exists to semantically encapsulate
mermaid code you want to render.
Again, note that the children indentation/spacing should be preserved using
JSX {} expression.
<Mermaid>
{`
graph TD
A[Client] --> B[Load Balancer]
B --> C[Server1]
B --> D[Server2]
`}
</Mermaid>Codeblock markdown
You can also render mermaid using code block.
However, add meta attribute render, to let the parser know
that we should render it into mermaid SVG
The following markdown code:
```mermaid render
flowchart
start --> finish
```Will render into this:
Supported Mermaid syntax
Too see or experiment with the Mermaid syntax, see: Mermaid Intro