diff options
author | Wang Chucheng <me@wangchucheng.com> | 2021-07-08 12:00:45 +0300 |
---|---|---|
committer | Wang Chucheng <me@wangchucheng.com> | 2021-07-08 12:00:45 +0300 |
commit | 9ffd36e6e03aeafec3a3c0778da0b7bb5b030b73 (patch) | |
tree | bbc3ee5ac20ffcd24582d7436c1265c5ee92bfa2 /layouts | |
parent | ccd5695125f1516db25424dc723eaa9fc6b3e87a (diff) |
fix: inconsistent utterances color scheme
Closes #122
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/comment/utterances.html | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/layouts/partials/comment/utterances.html b/layouts/partials/comment/utterances.html index e2f0471..56e632c 100644 --- a/layouts/partials/comment/utterances.html +++ b/layouts/partials/comment/utterances.html @@ -17,15 +17,21 @@ </script> <script> {{- if eq .Site.Params.colorScheme "light" }} - if ((storageColorScheme == 'Auto' && window.matchMedia("(prefers-color-scheme: dark)").matches) || storageColorScheme == "Dark") { + if (storageColorScheme == "Auto") { + document.getElementById('utterances').setAttribute('theme', 'preferred-color-scheme') + } else if (storageColorScheme == "Dark") { document.getElementById('utterances').setAttribute('theme', 'github-dark') } {{- else if eq .Site.Params.colorScheme "dark" }} - if ((storageColorScheme == 'Auto' && window.matchMedia("(prefers-color-scheme: light)").matches) || storageColorScheme == "Light") { + if (storageColorScheme == "Auto") { + document.getElementById('utterances').setAttribute('theme', 'preferred-color-scheme') + } else if (storageColorScheme == "Light") { document.getElementById('utterances').setAttribute('theme', 'github-light') } {{- else }} - if (((storageColorScheme == 'Auto' || storageColorScheme == null) && window.matchMedia("(prefers-color-scheme: dark)").matches) || storageColorScheme == "Dark") { + if (storageColorScheme == "Light") { + document.getElementById('utterances').setAttribute('theme', 'github-light') + } else if (storageColorScheme == "Dark") { document.getElementById('utterances').setAttribute('theme', 'github-dark') } {{- end }} |