This commit is contained in:
2026-03-28 16:50:54 +08:00
parent d99cf1bc78
commit 3e8cd729ba
2 changed files with 80 additions and 214 deletions
+25
View File
@@ -36,6 +36,29 @@
{{- partial "extend_footer.html" . }}
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
document.addEventListener("DOMContentLoaded", function() {
mermaid.initialize({ startOnLoad: true, theme: 'default' });
document.querySelectorAll('.language-mermaid').forEach(function(block) {
const container = block.closest('.highlight') || block.parentNode;
const div = document.createElement('div');
div.className = 'mermaid';
// Some Markdown parsers will escape < > " & etc.
// So we unescape them before sending to Mermaid
const txt = document.createElement("textarea");
txt.innerHTML = block.innerHTML;
div.textContent = txt.value;
if (container) {
container.parentNode.replaceChild(div, container);
}
});
});
</script>
<script>
let menu = document.getElementById('menu');
if (menu) {
@@ -152,3 +175,5 @@
});
</script>
{{- end }}