File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -191,12 +191,19 @@ canonical = System.fetch_env!("CANONICAL")
191191 before_closing_body_tag: fn
192192 :html ->
193193 """
194+ <script defer src="https://cdn.jsdelivr.net/npm/[email protected] /dist/mermaid.min.js"></script> 194195 <script>
195- function mermaidLoaded() {
196- mermaid.initialize({
197- startOnLoad: false,
198- theme: document.body.className.includes("dark") ? "dark" : "default"
199- });
196+ let initialized = false;
197+
198+ window.addEventListener("exdoc:loaded", () => {
199+ if (!initialized) {
200+ mermaid.initialize({
201+ startOnLoad: false,
202+ theme: document.body.className.includes("dark") ? "dark" : "default"
203+ });
204+ initialized = true;
205+ }
206+
200207 let id = 0;
201208 for (const codeEl of document.querySelectorAll("pre code.mermaid")) {
202209 const preEl = codeEl.parentElement;
@@ -210,9 +217,8 @@ canonical = System.fetch_env!("CANONICAL")
210217 preEl.remove();
211218 });
212219 }
213- }
220+ });
214221 </script>
215- <script async src="https://cdn.jsdelivr.net/npm/[email protected] /dist/mermaid.min.js" onload="mermaidLoaded();"></script> 216222 """
217223
218224 _ ->
You can’t perform that action at this time.
0 commit comments