feat: better preview for math and mermaid
This commit is contained in:
parent
8dc8e9ff97
commit
2a6d9b31f8
9 changed files with 46 additions and 54 deletions
|
@ -53,29 +53,10 @@
|
|||
*/}}
|
||||
|
||||
{{ if .Store.Get "hasMermaid" }}
|
||||
{{ partial "resource.html" (dict "context" . "type" "js" "filename" "js/load-mermaid.js") }}
|
||||
{{ partial "mermaid_support.html" . }}
|
||||
{{ end }}
|
||||
|
||||
{{ $colorTheme := "light" }}
|
||||
{{ if and (site.Params.colortheme) (ne site.Params.colortheme "") }}
|
||||
{{ $colorTheme = site.Params.colortheme | lower }}
|
||||
{{ end }}
|
||||
|
||||
<script type="module">
|
||||
function detectCurrentScheme3() {
|
||||
const defaultTheme = "{{ $colorTheme }}";
|
||||
if (localStorage !== null && localStorage.getItem("user-color-scheme")) {
|
||||
return localStorage.getItem("user-color-scheme");
|
||||
}
|
||||
if (defaultTheme === "dark" || defaultTheme === "light") {
|
||||
return defaultTheme;
|
||||
}
|
||||
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||
}
|
||||
|
||||
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
|
||||
window.mermaid = mermaid;
|
||||
window.initMermaid()
|
||||
document.body.dispatchEvent(new CustomEvent(detectCurrentScheme3() + "-theme-set"));
|
||||
</script>
|
||||
{{ if .Params.math }}
|
||||
{{ partial "mathjax_support.html" . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue