feat: add giscus theme customization (#522)

Co-authored-by: Xin <xin@imfing.com>
This commit is contained in:
Wonchae Yang 2024-12-26 21:29:21 +09:00 committed by GitHub
parent 9efcda2fdd
commit 0716533699
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -173,3 +173,4 @@ params:
# emitMetadata: 0
# inputPosition: top
# lang: en
# theme: noborder_dark

View File

@ -8,10 +8,19 @@
* 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) {
const iframe = document.querySelector('iframe.giscus-frame');