fix: make Disqus / Utterances follow the global color scheme (#111)
* fix: make Disqus / Utterances follow the global color scheme * fix: check if DISQUS exists before executing DISQUS.reset closes https://github.com/CaiJimmy/hugo-theme-stack/issues/107
This commit is contained in:
@@ -10,3 +10,13 @@
|
||||
padding: var(--card-padding);
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
window.addEventListener('onColorSchemeChange', (e) => {
|
||||
if (DISQUS) {
|
||||
DISQUS.reset({
|
||||
reload: true
|
||||
});
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -14,3 +14,18 @@
|
||||
max-width: unset;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
window.addEventListener('onColorSchemeChange', (e) => {
|
||||
let utterances = document.querySelector('.utterances iframe');
|
||||
if (utterances) {
|
||||
utterances.contentWindow.postMessage(
|
||||
{
|
||||
type: 'set-theme',
|
||||
theme: `github-${e.detail}`
|
||||
},
|
||||
'https://utteranc.es'
|
||||
);
|
||||
}
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user