1
0
Fork 0
freesewing/sites/shared/components/mdx/mermaid.mjs
Joost De Cock 4cd2eff9a3 feat(shared): Add Mermaid support to MDX pipeline
At the request of @marpants this adds support for mermaid diagrams to
our shared MDX pipeline. Diagrams can be created by using a fenced code
block using the `mermaid` language.

I did not verify to what extend this bloats the bundle. Perhaps that's
something we need to look into later and consider the trade-off. For
now, my main concern is to keep a new contributor happy, so here it goes
:)
2023-04-17 19:58:33 +02:00

15 lines
344 B
JavaScript

import { useEffect } from 'react'
import mermaid from 'mermaid'
mermaid.initialize({
startOnLoad: true,
})
export const Mermaid = ({ children }) => {
const chart = children.props.children
console.log({ chart })
useEffect(() => {
mermaid.contentLoaded()
}, [])
return <div className="mermaid">{children.props.children}</div>
}