mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-06-18 20:13:31 +08:00
format
This commit is contained in:
parent
020d693d20
commit
3fe51d0d6b
@ -14,36 +14,35 @@
|
||||
></script>
|
||||
<script>
|
||||
function setGiscusTheme(theme) {
|
||||
let giscus = document.querySelector('iframe.giscus-frame');
|
||||
let giscus = document.querySelector("iframe.giscus-frame");
|
||||
if (giscus) {
|
||||
giscus.contentWindow.postMessage(
|
||||
{
|
||||
{
|
||||
giscus: {
|
||||
setConfig: {
|
||||
theme: theme
|
||||
}
|
||||
}
|
||||
setConfig: {
|
||||
theme: theme,
|
||||
},
|
||||
},
|
||||
},
|
||||
"https://giscus.app"
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
(function(){
|
||||
addEventListener('message', (e) => {
|
||||
if (event.origin !== 'https://giscus.app') return;
|
||||
handler()
|
||||
(function () {
|
||||
addEventListener("message", (e) => {
|
||||
if (event.origin !== "https://giscus.app") return;
|
||||
handler();
|
||||
});
|
||||
window.addEventListener('onColorSchemeChange', handler);
|
||||
window.addEventListener("onColorSchemeChange", handler);
|
||||
|
||||
function handler() {
|
||||
if (document.documentElement.dataset.scheme === "light") {
|
||||
setGiscusTheme('{{- default "light" .lightTheme -}}');
|
||||
} else {
|
||||
setGiscusTheme('{{- default "dark_dimmed" .darkTheme -}}');
|
||||
};
|
||||
};
|
||||
}());
|
||||
}
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
{{- end -}}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user