summaryrefslogtreecommitdiff
path: root/layouts/partials/footer.html
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/partials/footer.html')
-rw-r--r--layouts/partials/footer.html20
1 files changed, 19 insertions, 1 deletions
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index ff5cdd5..edf86ac 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -44,4 +44,22 @@
function menu_on_scroll() {
localStorage.setItem("menu-scroll-position", document.getElementById('menu').scrollLeft);
}
-</script> \ No newline at end of file
+</script>
+{{- if not .Site.Params.disableThemeToggle }}
+<script>
+ document.getElementById("theme-toggle").addEventListener("click", () => {
+ if (document.body.className.includes("dark")) {
+ document.body.classList.remove('dark');
+ localStorage.setItem("pref-theme", 'light');
+ } else {
+ document.body.classList.add('dark');
+ localStorage.setItem("pref-theme", 'dark');
+ }
+ })
+</script>
+{{- else -}}
+<!-- case where owner disables theme button after deployment, this resets the stored theme -->
+<script>
+ localStorage.removeItem("pref-theme");
+</script>
+{{- end }} \ No newline at end of file