Last active
January 5, 2023 14:33
-
-
Save Viiprogrammer/eb6066c0d8fb3708b79a644a26142221 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect } from 'react' | |
import { useColorMode } from '@docusaurus/theme-common'; | |
import mermaid from "mermaid"; | |
mermaid.initialize({ | |
startOnLoad: true, | |
theme: 'neutral' | |
}); | |
const Mermaid = ({ chart }) => { | |
const { colorMode } = useColorMode(); | |
useEffect(() => { | |
mermaid.contentLoaded() | |
}); | |
return <div className="mermaid">{`%%{init: {'theme':'${colorMode === 'dark' ? 'dark' : 'neutral' }'}}%%`}{chart}</div>; | |
}; | |
export default Mermaid; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: