Configure Mermaid Renderer โ
Environment: client
This setup function will only run on client side. Make sure the browser compatibility when importing packages.
- The user installs the Mermaid library they want to use. e.g.)
npm install beautiful-mermaid - Create
./setup/mermaid-renderer.tswith the following content:
ts
// setup/mermaid-renderer.ts
import { defineMermaidRendererSetup } from '@slidev/types'
// example. https://github.com/lukilabs/beautiful-mermaid?tab=readme-ov-file#readme
import { renderMermaid } from 'beautiful-mermaid'
export default defineMermaidRendererSetup(() => {
return (code, _options) => renderMermaid(code)
})This setting allows you to use the 3rd party Mermaid library. Replace the renderMermaid() part with the render function of the library.