diff --git a/layouts/partials/giscus.html b/layouts/partials/giscus.html index 23f493a..eb6ce65 100644 --- a/layouts/partials/giscus.html +++ b/layouts/partials/giscus.html @@ -1,23 +1,24 @@ -{{ $theme := .Site.Params.GiscusTheme | default "preferred_color_scheme" }} -{{ $mapping := .Site.Params.GiscusDataMapping | default "og:title" }} -{{ $language := .Site.Params.GiscusLang | default "en" }} -{{ $category := .Site.Params.GiscusDiscussionCategory | default "Announcements" }} -{{ $lazyload := .Site.Params.GiscusLazyLoad | default false }} +{{ $theme := .Site.Params.GiscusTheme | default "preferred_color_scheme" }} {{ $mapping := +.Site.Params.GiscusDataMapping | default "og:title" }} {{ $language := .Site.Params.GiscusLang | default "en" }} {{ +$category := .Site.Params.GiscusDiscussionCategory | default "Announcements" }} {{ $lazyload +:= .Site.Params.GiscusLazyLoad | default false }} {{ $colorTheme := "auto" }} {{ if and (isset site.Params "colortheme") +(ne site.Params.colortheme "") }} {{ $colorTheme = site.Params.colortheme | lower }} {{ end }} -{{/* - */}} +{{/* + +*/}} \ No newline at end of file diff --git a/layouts/partials/theme-switcher.html b/layouts/partials/theme-switcher.html index 65d3943..8ad76de 100644 --- a/layouts/partials/theme-switcher.html +++ b/layouts/partials/theme-switcher.html @@ -26,7 +26,8 @@ const autoChangeScheme = e => { currentTheme = e.matches ? 'dark' : 'light' - document.documentElement.setAttribute('data-theme', currentTheme) + document.documentElement.setAttribute('data-theme', currentTheme); + changeGiscusTheme(currentTheme); } document.addEventListener('DOMContentLoaded', function () { @@ -61,7 +62,7 @@ currentTheme = (currentTheme === 'dark') ? 'light' : 'dark'; if (localStorage) localStorage.setItem(STORAGE_KEY, currentTheme); document.documentElement.setAttribute('data-theme', currentTheme); - changeGiscusTheme(); + changeGiscusTheme(currentTheme); } function showContent() { @@ -69,9 +70,7 @@ document.body.style.opacity = 1; } - function changeGiscusTheme () { - const theme = detectCurrentScheme(); - + function changeGiscusTheme (theme) { function sendMessage(message) { const iframe = document.querySelector('iframe.giscus-frame'); if (!iframe) return;