mirror of
https://github.com/imfing/hextra.git
synced 2025-06-20 01:12:03 -04:00
feat: add theme switcher to support dark mode
This commit is contained in:
@ -8,7 +8,16 @@
|
||||
{{ $styles := resources.Get "css/styles.css" }}
|
||||
{{ $styles = $styles | resources.PostCSS $options }}
|
||||
{{ if hugo.IsProduction }}
|
||||
{{ $styles = $styles | minify | fingerprint | resources.PostProcess }}
|
||||
{{ $styles = $styles | minify | fingerprint | resources.PostProcess }}
|
||||
{{ end }}
|
||||
<link href="{{ $styles.RelPermalink }}" rel="stylesheet" />
|
||||
|
||||
<script>
|
||||
/* Initialize light/dark mode */
|
||||
if (localStorage.getItem("color-theme") === "dark" || (!("color-theme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches)) {
|
||||
document.documentElement.classList.add("dark");
|
||||
} else {
|
||||
document.documentElement.classList.remove("dark");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
Reference in New Issue
Block a user