mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-29 20:13:31 +08:00
update
This commit is contained in:
parent
aeaddc96dc
commit
0412cadfcf
@ -13,9 +13,6 @@
|
|||||||
async
|
async
|
||||||
></script>
|
></script>
|
||||||
<script>
|
<script>
|
||||||
const light = '{{- default "light" .lightTheme -}}';
|
|
||||||
const dark = '{{- default "dark_dimmed" .darkTheme -}}';
|
|
||||||
const head = document.getElementsByTagName("html")[0];
|
|
||||||
|
|
||||||
function setGiscusTheme(theme) {
|
function setGiscusTheme(theme) {
|
||||||
let giscus = document.querySelector('iframe.giscus-frame');
|
let giscus = document.querySelector('iframe.giscus-frame');
|
||||||
@ -27,19 +24,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addEventListener('message', event => {
|
(function(){
|
||||||
if (event.origin !== 'https://giscus.app') return;
|
const head = document.getElementsByTagName("html")[0];
|
||||||
if (head.getAttribute("data-scheme") == "dark") {
|
|
||||||
setGiscusTheme(dark);
|
addEventListener('message', handler)
|
||||||
}
|
window.addEventListener('onColorSchemeChange', handler)
|
||||||
})
|
|
||||||
window.addEventListener('onColorSchemeChange', event => {
|
function handler() {
|
||||||
if (head.getAttribute("data-scheme") == "light") {
|
if (head.getAttribute("data-scheme") == "light") {
|
||||||
setGiscusTheme(light);
|
setGiscusTheme('{{- default "light" .lightTheme -}}');
|
||||||
} else {
|
} else {
|
||||||
setGiscusTheme(dark);
|
setGiscusTheme('{{- default "dark_dimmed" .darkTheme -}}');
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
}());
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
Loading…
Reference in New Issue
Block a user