mirror of
https://github.com/tomfran/typo.git
synced 2025-04-26 13:39:55 +03:00
Merge pull request #86 from OleMussmann/configure-mermaid-theme
Configure mermaid theme
This commit is contained in:
commit
24dc86184b
5 changed files with 73 additions and 39 deletions
|
@ -34,38 +34,6 @@
|
|||
|
||||
</body>
|
||||
|
||||
<script>
|
||||
|
||||
function isAuto() {
|
||||
return document.body.classList.contains("auto");
|
||||
}
|
||||
|
||||
function setTheme() {
|
||||
if (!isAuto()) {
|
||||
return
|
||||
}
|
||||
|
||||
document.body.classList.remove("auto");
|
||||
let cls = "light";
|
||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
cls = "dark";
|
||||
}
|
||||
|
||||
document.body.classList.add(cls);
|
||||
}
|
||||
|
||||
function invertBody() {
|
||||
document.body.classList.toggle("dark");
|
||||
document.body.classList.toggle("light");
|
||||
}
|
||||
|
||||
if (isAuto()) {
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addListener(invertBody);
|
||||
}
|
||||
|
||||
setTheme();
|
||||
|
||||
</script>
|
||||
|
||||
<script src="{{ "js/theme-switch.js" | relURL }}"></script>
|
||||
<script defer src="{{ "js/copy-code.js" | relURL }}"></script>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -73,13 +73,17 @@
|
|||
</div>
|
||||
|
||||
{{ if .Store.Get "hasMermaid" }}
|
||||
<script type="module">
|
||||
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
|
||||
mermaid.initialize({ startOnLoad: true });
|
||||
{{ $mermaidDarkTheme := default "dark" (or .Params.mermaidDarkTheme .Site.Params.mermaidDarkTheme) }}
|
||||
{{ $mermaidTheme := default "default" (or .Params.mermaidTheme .Site.Params.mermaidTheme) }}
|
||||
<script defer
|
||||
type="module"
|
||||
id="mermaid_script"
|
||||
data-light-theme="{{ $mermaidTheme }}"
|
||||
data-dark-theme="{{ $mermaidDarkTheme }}"
|
||||
src='{{ "js/mermaid.js" | relURL }}'>
|
||||
</script>
|
||||
{{ end }}
|
||||
|
||||
|
||||
{{/* Next prev controls */}}
|
||||
|
||||
{{ if not (.Param "hidePagination") }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue