2020-10-04 10:23:08 -04:00
|
|
|
<script src="https://utteranc.es/client.js"
|
|
|
|
repo="{{ .Site.Params.comments.utterances.repo }}"
|
|
|
|
issue-term="{{ .Site.Params.comments.utterances.issueTerm }}"
|
|
|
|
{{ with .Site.Params.comments.utterances.label }}
|
|
|
|
label="{{ . }}"
|
|
|
|
{{ end }}
|
2021-02-11 12:46:23 -05:00
|
|
|
crossorigin="anonymous"
|
|
|
|
async
|
|
|
|
>
|
2020-10-04 10:23:08 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.utterances {
|
|
|
|
max-width: unset;
|
|
|
|
}
|
2021-01-01 07:32:19 -05:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<script>
|
2022-12-06 08:55:40 -05:00
|
|
|
let utterancesLoaded = false;
|
|
|
|
|
2021-02-11 12:46:23 -05:00
|
|
|
function setUtterancesTheme(theme) {
|
2021-01-01 07:32:19 -05:00
|
|
|
let utterances = document.querySelector('.utterances iframe');
|
|
|
|
if (utterances) {
|
|
|
|
utterances.contentWindow.postMessage(
|
|
|
|
{
|
|
|
|
type: 'set-theme',
|
2021-02-11 12:46:23 -05:00
|
|
|
theme: `github-${theme}`
|
2021-01-01 07:32:19 -05:00
|
|
|
},
|
|
|
|
'https://utteranc.es'
|
|
|
|
);
|
|
|
|
}
|
2021-02-11 12:46:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
addEventListener('message', event => {
|
|
|
|
if (event.origin !== 'https://utteranc.es') return;
|
2022-12-06 08:55:40 -05:00
|
|
|
|
|
|
|
/// Called when Utterances is ready
|
|
|
|
utterancesLoaded = true;
|
2021-06-20 09:49:35 -04:00
|
|
|
setUtterancesTheme(document.documentElement.dataset.scheme)
|
2021-02-11 12:46:23 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
window.addEventListener('onColorSchemeChange', (e) => {
|
2022-12-06 08:55:40 -05:00
|
|
|
if (!utterancesLoaded) return;
|
2021-02-11 12:46:23 -05:00
|
|
|
setUtterancesTheme(e.detail)
|
2021-01-01 07:32:19 -05:00
|
|
|
})
|
2021-06-20 09:49:35 -04:00
|
|
|
</script>
|