mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-27 23:04:05 -06:00
use mermaid.init() to render diagrams for SPA.
mermaid.initialize({startOnLoad: true}) relies on the DOMContentLoaded
event to trigger rendering of markdown to svg. mermaid.init() bypasses
this behavior, but is deprecated.
This commit is contained in:
parent
9d71041aca
commit
3cb51a4289
@ -147,6 +147,19 @@
|
||||
|
||||
}
|
||||
{{end}}
|
||||
|
||||
{{if $data.enableMermaid | default $.Site.Data.config.enableMermaid}}
|
||||
var els = document.getElementsByClassName("mermaid");
|
||||
if (els.length > 0) {
|
||||
import('https://unpkg.com/mermaid@9/dist/mermaid.esm.min.mjs').then(
|
||||
(obj) => {
|
||||
// init forces mermaid to render mermaid markdown without waiting
|
||||
// for DOMContentLoaded event
|
||||
obj.default.init();
|
||||
}
|
||||
)
|
||||
}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
const init = (doc = document) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user