compose-theme/layouts/partials/scripts/mermaid.html
2024-07-26 17:08:59 +02:00

25 lines
No EOL
579 B
HTML

{{ if in .Content "mermaid" }}
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
let theme_input = elem('.color_choice');
let key = theme_input.value;
function getTheme(mode) {
return key == 'dark' ? 'dark' : 'base';
}
function initializeMermaid(mode) {
mermaid.initialize(
{ startOnLoad: true, theme: getTheme(mode) }
);
}
initializeMermaid(key);
theme_input.addEventListener('change', e => {
location.reload();
initializeMermaid(e.target.value);
});
</script>
{{ end }}