From 0716533699943fcce388d68811403f4835fc0988 Mon Sep 17 00:00:00 2001 From: Wonchae Yang <79977182+ywonchae1@users.noreply.github.com> Date: Thu, 26 Dec 2024 21:29:21 +0900 Subject: [PATCH] feat: add giscus theme customization (#522) Co-authored-by: Xin --- exampleSite/hugo.yaml | 1 + layouts/partials/components/giscus.html | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/exampleSite/hugo.yaml b/exampleSite/hugo.yaml index d2c03d08..c8c3301e 100644 --- a/exampleSite/hugo.yaml +++ b/exampleSite/hugo.yaml @@ -173,3 +173,4 @@ params: # emitMetadata: 0 # inputPosition: top # lang: en + # theme: noborder_dark diff --git a/layouts/partials/components/giscus.html b/layouts/partials/components/giscus.html index 8f7edf0f..84148c26 100644 --- a/layouts/partials/components/giscus.html +++ b/layouts/partials/components/giscus.html @@ -8,9 +8,18 @@ * This solution was created with reference to: * https://github.com/giscus/giscus/issues/336#issuecomment-1214366281 */ - function getGiscusTheme() { + function getHugoTheme() { return localStorage.getItem("color-theme"); } + + function getGiscusTheme() { + let giscusTheme = "{{ (string .theme) | default `light` }}"; + if(getHugoTheme() == 'light') { + return giscusTheme.replace('dark', 'light'); + } else { + return giscusTheme.replace('light', 'dark'); + } + } function setGiscusTheme() { function sendMessage(message) {