Skip to content

Commit

Permalink
feat: add giscus theme customization (#522)
Browse files Browse the repository at this point in the history
Co-authored-by: Xin <[email protected]>
  • Loading branch information
ywonchae1 and imfing authored Dec 26, 2024
1 parent 9efcda2 commit 0716533
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions exampleSite/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,4 @@ params:
# emitMetadata: 0
# inputPosition: top
# lang: en
# theme: noborder_dark
11 changes: 10 additions & 1 deletion layouts/partials/components/giscus.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0716533

Please sign in to comment.