web/_includes/mermaid.html
2020-12-10 05:00:01 +08:00

28 lines
698 B
HTML

<!--
mermaid-js loader
-->
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<script>
let initTheme = "default";
if ($("html[mode=dark]").length > 0
|| ($("html[mode]").length == 0
&& window.matchMedia("(prefers-color-scheme: dark)").matches ) ) {
initTheme = "dark";
}
let mermaidConf = {
theme: initTheme /* <default|dark|forest|neutral> */
};
/* Markdown converts to HTML */
$("pre").has("code.language-mermaid").each(function() {
let svgCode = $(this).children().html();
$(this).addClass("unloaded");
$(this).after(`<div class=\"mermaid\">${svgCode}</div>`);
});
mermaid.initialize(mermaidConf);
</script>