diff --git a/layouts/partials/theme-switcher.html b/layouts/partials/theme-switcher.html
index a2e22f9..90e85f5 100644
--- a/layouts/partials/theme-switcher.html
+++ b/layouts/partials/theme-switcher.html
@@ -1,79 +1,65 @@
{{ $style := "light-without-switcher" }}
{{ if and (isset site.Params "style") (ne site.Params.style "") }}
- {{ $style = site.Params.style | lower }}
+{{ $style = site.Params.style | lower }}
{{ end }}
{{ if not (in (slice "light-without-switcher" "dark-without-switcher") $style) }}
- {{ if ne "auto-without-switcher" $style }}
-
- {{ partial "font-awesome.html" (dict "iconName" "theme-light" "custom" false) }}
-
- {{ end }}
+{{ if ne "auto-without-switcher" $style }}
+
+ {{ partial "font-awesome.html" (dict "iconName" "theme-light" "custom" false) }}
+
+{{ end }}
-
-{{ end }}
+ if (defaultTheme) {
+ return defaultTheme
+ }
+ return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
+ }
+
+ function switchTheme(e) {
+ currentTheme = (currentTheme === 'dark') ? 'light' : 'dark';
+ if (localStorage) localStorage.setItem(STORAGE_KEY, currentTheme);
+ document.documentElement.setAttribute('data-theme', currentTheme);
+ }
+
+ function showContent() {
+ document.body.style.visibility = 'visible';
+ document.body.style.opacity = 1;
+ }
+
+{{ end }}
\ No newline at end of file