Skip to content

Commit 0fb2f63

Browse files
authored
fix: move mermaid script to before_closing_body_tag for proper rendering (#289)
Mermaid diagrams were rendering as code blocks instead of images because the script was loaded in the head tag before the DOM content was available. Moving to `before_closing_body_tag` ensures the script runs after all page content is loaded, allowing mermaid to find and transform the code blocks. Closes #287
1 parent 6f7c937 commit 0fb2f63

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

mix.exs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,7 @@ defmodule Reactor.MixProject do
5757
before_closing_head_tag: fn type ->
5858
if type == :html do
5959
"""
60-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js"></script>
6160
<script>
62-
mermaid.initialize({
63-
startOnLoad: true,
64-
theme: 'default'
65-
});
66-
6761
if (location.hostname === "hexdocs.pm") {
6862
var script = document.createElement("script");
6963
script.src = "https://plausible.io/js/script.js";
@@ -75,6 +69,19 @@ defmodule Reactor.MixProject do
7569
"""
7670
end
7771
end,
72+
before_closing_body_tag: fn type ->
73+
if type == :html do
74+
"""
75+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js"></script>
76+
<script>
77+
mermaid.initialize({
78+
startOnLoad: true,
79+
theme: 'default'
80+
});
81+
</script>
82+
"""
83+
end
84+
end,
7885
groups_for_modules: [
7986
Dsl: ~r/^Reactor\.Dsl.*/,
8087
Steps: ~r/^Reactor\.Step.*/,

0 commit comments

Comments
 (0)