kanidm/book/mermaid-init.js
Matthew Wilks e530cde361
Diagram Improvements in Book (#3124)
* Bump mermaid to 11.3.0
* Mermaid theme changes based on mdbook theme
* Replace old use cases diagram with mermaid one
* Change out ASCII git art with mermaid git graph
* Remove old theme.css file from book
2024-10-19 23:46:29 +00:00

13 lines
487 B
JavaScript

//* Changes mermaid theme based on selected mdbook theme
const rootElement = document.documentElement;
const darkThemes = ["coal", "navy", "ayu"];
// Get the intersection of the HTML element class list & mdbook's dark themes
const selectedDarkTheme = [...rootElement.classList].filter((c) => darkThemes.includes(c));
if (selectedDarkTheme.length > 0) {
mermaid.initialize({ startOnLoad: true, theme: "dark" });
} else {
mermaid.initialize({ startOnLoad: true, theme: "default" });
}