theme-switch: Enable theme toggle unless specifically disabled (#69)
Co-authored-by: Aditya Telange <21258296+adityatelange@users.noreply.github.com>
This commit is contained in:
parent
12b6b132e4
commit
3064e8cfc5
2 changed files with 22 additions and 11 deletions
|
|
@ -50,7 +50,7 @@
|
|||
localStorage.setItem("menu-scroll-position", document.getElementById('menu').scrollLeft);
|
||||
}
|
||||
</script>
|
||||
{{- if (and (not .Site.Params.disableThemeToggle) (not (or (eq .Site.Params.defaultTheme "light") (eq .Site.Params.defaultTheme "dark")))) }}
|
||||
{{- if (not .Site.Params.disableThemeToggle) }}
|
||||
<script>
|
||||
document.getElementById("theme-toggle").addEventListener("click", () => {
|
||||
if (document.body.className.includes("dark")) {
|
||||
|
|
@ -63,7 +63,7 @@
|
|||
})
|
||||
</script>
|
||||
{{- else -}}
|
||||
<!-- case where owner disables theme button after deployment, this resets the stored theme -->
|
||||
{{/* case where owner disables theme button after deployment, this resets the stored theme */}}
|
||||
<script>
|
||||
localStorage.removeItem("pref-theme");
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue