mirror of
https://github.com/docker/docs.git
synced 2026-06-19 07:35:16 +00:00
9789556384
Adds a Hugo codeblock render hook that turns ```mermaid fences into <pre class="mermaid"> containers, plus a lazily-loaded mermaid bundle that only ships on pages that actually contain a diagram. Mirrors the existing YouTube embed pattern (Store flag + conditional script tag in baseof) so the main scripts.js bundle stays unchanged.
20 lines
412 B
JavaScript
20 lines
412 B
JavaScript
import mermaid from 'mermaid'
|
|
|
|
const isDark = () => document.documentElement.classList.contains('dark')
|
|
|
|
mermaid.initialize({
|
|
startOnLoad: false,
|
|
securityLevel: 'strict',
|
|
theme: isDark() ? 'dark' : 'default',
|
|
})
|
|
|
|
const render = () => {
|
|
mermaid.run({ querySelector: 'pre.mermaid' })
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', render)
|
|
} else {
|
|
render()
|
|
}
|