diff options
| author | Nikita Shubin <nikita.shubin@maquefel.me> | 2026-06-14 15:31:07 +0300 |
|---|---|---|
| committer | Serge Semin <fancer.lancer@gmail.com> | 2026-07-24 00:10:06 +0300 |
| commit | 74f4d0a13233ab6251cf891734222b5244f931b1 (patch) | |
| tree | aa7644e7f10df7f247cc567ead1f158ce761c689 | |
| parent | 0833b5654b53034fff7be34ea917db93c39b9976 (diff) | |
| download | landau.one-74f4d0a13233ab6251cf891734222b5244f931b1.tar.gz landau.one-74f4d0a13233ab6251cf891734222b5244f931b1.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> |
