diff options
| author | Nikita Shubin <nikita.shubin@maquefel.me> | 2026-06-14 15:31:07 +0300 |
|---|---|---|
| committer | Dmitry Rokosov <rockosov@rulkc.org> | 2026-07-08 15:57:52 +0300 |
| commit | de1a3b857038a1328784e9c70125d68d8856db1a (patch) | |
| tree | ac1d10d142bd8cdbb7bdc01db3a8e5dc580d090e | |
| parent | a060a5f1a38757d437bb9ee5f12838e3114a4518 (diff) | |
| download | landau.one-de1a3b857038a1328784e9c70125d68d8856db1a.tar.gz landau.one-de1a3b857038a1328784e9c70125d68d8856db1a.zip | |
mermaid: Add mermaid workaround
For upstream hugo the only possiblity for mermaid rendering is using
external js script.
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
Signed-off-by: Dmitry Rokosov <rockosov@rulkc.org>
| -rw-r--r-- | layouts/partials/head-additions.html | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/layouts/partials/head-additions.html b/layouts/partials/head-additions.html new file mode 100644 index 0000000..0aa1935 --- /dev/null +++ b/layouts/partials/head-additions.html @@ -0,0 +1,26 @@ +<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script> +<script> + document.addEventListener('DOMContentLoaded', function() { + // Look for mermaid code blocks + const mermaidBlocks = document.querySelectorAll('pre code.language-mermaid'); + if (mermaidBlocks.length > 0) { + mermaid.initialize({ + startOnLoad: false, + theme: 'default', + flowchart: { + useMaxWidth: true + } + }); + + mermaidBlocks.forEach((block, index) => { + const graphDefinition = block.textContent; + const div = document.createElement('div'); + div.className = 'mermaid'; + div.innerHTML = graphDefinition; + block.parentNode.parentNode.replaceChild(div, block.parentNode); + }); + + mermaid.init(); + } + }); +</script> |
