diff --git a/assets/js/darkmode.js b/assets/js/darkmode.js
index 109db12..9198a97 100644
--- a/assets/js/darkmode.js
+++ b/assets/js/darkmode.js
@@ -1,7 +1,3 @@
-if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches && localStorage.getItem('dark-mode') === null) {
- localStorage.setItem('dark-mode', 'true');
-}
-
function darkmode() {
if (localStorage.getItem('dark-mode') === 'false') {
darkmode_enable();
@@ -20,4 +16,8 @@ function darkmode_enable() {
function darkmode_disable() {
document.body.classList.remove("dark-mode");
localStorage.setItem('dark-mode', 'false');
+}
+
+if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches && localStorage.getItem('dark-mode') === null) {
+ localStorage.setItem('dark-mode', 'true');
}
\ No newline at end of file
diff --git a/assets/js/darkmode_click.js b/assets/js/darkmode_click.js
new file mode 100644
index 0000000..c726001
--- /dev/null
+++ b/assets/js/darkmode_click.js
@@ -0,0 +1 @@
+document.getElementById("dark-mode-button").addEventListener("click", darkmode);
\ No newline at end of file
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 5305b1a..4ef0051 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -63,6 +63,15 @@
Simply place a custom_body.html into
your local /layouts/partials-directory -->
{{- partial "custom_body.html" . -}}
+
+ {{- /* Onclick Javascript */}}
+ {{- $darkmode_onclick := (resources.Get "js/darkmode_click.js") | resources.Minify }}
+ {{- if not site.Params.assets.disableFingerprinting }}
+ {{- $darkmode_onclick := $darkmode_onclick | fingerprint }}
+
+ {{ else }}
+
+ {{ end }}