diff --git a/assets/js/theme.js b/assets/js/theme.js new file mode 100644 index 0000000..be17dc9 --- /dev/null +++ b/assets/js/theme.js @@ -0,0 +1,9 @@ +// for now this is assuming default theme is set to dark +// will probably refactor in the future for much better handling +function loadPreferredTheme() { + if (localStorage.getItem("pref-theme") === "light") { + document.body.classList.remove('dark') + } +} + +loadPreferredTheme(); \ No newline at end of file diff --git a/layouts/partials/header.html b/layouts/partials/header.html new file mode 100644 index 0000000..b25f852 --- /dev/null +++ b/layouts/partials/header.html @@ -0,0 +1,118 @@ +{{- /* theme.js */}} +{{- if not site.Params.disableThemeToggle }} +{{- $theme := resources.Get "js/theme.js" | resources.Minify }} +{{- if not site.Params.assets.disableFingerprinting }} +{{- $theme_js := (slice $theme) | resources.Concat "assets/js/theme.js" | fingerprint }} + +{{- else }} +{{- $theme_js := (slice $theme) | resources.Concat "assets/js/theme.js" }} + +{{- end }} +{{- end }} + +
+ +