Skip to content

Commit 1b5187d

Browse files
committed
fix: initialize mermaid after DOM being ready
1 parent 0d52932 commit 1b5187d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

otterwiki/templates/snippets/renderer_js.html

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
<script id="MathJax-script" async src="{{ url_for("static", filename="mathjax/tex-chtml.js") }}"></script>
44
<script src="{{ url_for("static", filename="js/[email protected]") }}"></script>
55
<script type="text/javascript">
6-
mermaid.initialize({
7-
{%- if request.cookies.get('halfmoon_preferredMode') == "dark-mode" %}
8-
theme: 'dark',
9-
{%- else %}
10-
theme: 'neutral',
11-
{%- endif %}
6+
document.addEventListener("DOMContentLoaded", function(event) {
7+
let theme = 'neutral';
8+
if (document.querySelector("body").classList.contains("dark-mode")) {
9+
theme = 'dark';
10+
}
11+
mermaid.initialize({
12+
theme: theme,
13+
});
1214
});
1315
</script>

0 commit comments

Comments
 (0)