From a03f248319a982926788c5a72356eec408dc66fd Mon Sep 17 00:00:00 2001
From: bb1950328 <bb1950328@gmail.com>
Date: Wed, 27 Jan 2021 15:33:04 +0000
Subject: [PATCH] light/dark mode switch improvements and bugfix in search index (#29)

---
 layouts/partials/mode.html |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/layouts/partials/mode.html b/layouts/partials/mode.html
index 29af215..d1cb403 100644
--- a/layouts/partials/mode.html
+++ b/layouts/partials/mode.html
@@ -1,4 +1,16 @@
+{{- $s := .Site }}
+{{- $sp := $s.Params }}
+{{- $iconsPath := "icons/" }}
 <div class = 'color_mode'>
-  <label for = 'mode'></label>
+  <label for = 'mode'>
+    {{- $litPath := absURL (printf "%ssun.svg" $iconsPath) }}
+    {{- $darkPath := absURL (printf "%smoon.svg" $iconsPath) }}
+    <picture data-lit="{{ $litPath }}" data-dark="{{ $darkPath }}">
+      {{ with $sp.enableDarkMode }}
+        <source srcset = '{{ $darkPath }}' media="(prefers-color-scheme: dark)">
+      {{ end }}
+      <img srcset = '{{ $litPath }}' alt = 'Light/Dark Mode Icon' class="color_icon">
+    </picture>
+  </label>
   <input type = 'checkbox' class = 'color_choice' id = 'mode' title="Toggle Dark Mode">
 </div>

--
Gitblit v1.10.0