-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
225 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,37 @@ defmodule Tower.MixProject do | |
main: "Tower", | ||
extras: [ | ||
"CHANGELOG.md": [title: "Changelog"] | ||
] | ||
], | ||
before_closing_body_tag: &before_closing_body_tag/1 | ||
] | ||
end | ||
|
||
defp before_closing_body_tag(:html) do | ||
""" | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js"></script> | ||
<script> | ||
document.addEventListener("DOMContentLoaded", function () { | ||
mermaid.initialize({ | ||
startOnLoad: false, | ||
theme: document.body.className.includes("dark") ? "dark" : "default" | ||
}); | ||
let id = 0; | ||
for (const codeEl of document.querySelectorAll("pre code.mermaid")) { | ||
const preEl = codeEl.parentElement; | ||
const graphDefinition = codeEl.textContent; | ||
const graphEl = document.createElement("div"); | ||
const graphId = "mermaid-graph-" + id++; | ||
mermaid.render(graphId, graphDefinition).then(({svg, bindFunctions}) => { | ||
graphEl.innerHTML = svg; | ||
bindFunctions?.(graphEl); | ||
preEl.insertAdjacentElement("afterend", graphEl); | ||
preEl.remove(); | ||
}); | ||
} | ||
}); | ||
</script> | ||
""" | ||
end | ||
|
||
defp before_closing_body_tag(_), do: "" | ||
end |