2021-12-11 12:24:08 +03:00
|
|
|
<!-- https://utteranc.es/ -->
|
2024-11-16 17:49:55 +03:00
|
|
|
<script>
|
2023-09-14 20:24:13 +03:00
|
|
|
(function () {
|
2023-09-14 20:13:20 +03:00
|
|
|
const origin = 'https://utteranc.es';
|
2024-11-16 17:49:55 +03:00
|
|
|
const themeMapper = Theme.getThemeMapper('github-light', 'github-dark');
|
|
|
|
const initTheme = themeMapper[Theme.visualState];
|
|
|
|
|
|
|
|
let script = document.createElement('script');
|
|
|
|
script.src = 'https://utteranc.es/client.js';
|
|
|
|
script.setAttribute('repo', '{{ site.comments.utterances.repo }}');
|
|
|
|
script.setAttribute('issue-term', '{{ site.comments.utterances.issue_term }}');
|
|
|
|
script.setAttribute('theme', initTheme);
|
|
|
|
script.crossOrigin = 'anonymous';
|
|
|
|
script.async = true;
|
2021-12-11 12:24:08 +03:00
|
|
|
|
2024-11-16 17:49:55 +03:00
|
|
|
const $footer = document.querySelector('footer');
|
|
|
|
$footer.insertAdjacentElement('beforebegin', script);
|
2021-12-11 12:24:08 +03:00
|
|
|
|
2023-09-14 20:13:20 +03:00
|
|
|
addEventListener('message', (event) => {
|
2024-11-16 17:49:55 +03:00
|
|
|
let newTheme;
|
2021-12-11 12:24:08 +03:00
|
|
|
|
2024-11-16 17:49:55 +03:00
|
|
|
{%- comment -%}
|
|
|
|
Credit to <https://github.com/utterance/utterances/issues/170#issuecomment-594036347>
|
|
|
|
{%- endcomment -%}
|
|
|
|
if (event.source === window && event.data && event.data.id === Theme.ID) {
|
|
|
|
newTheme = themeMapper[Theme.visualState];
|
2021-12-11 12:24:08 +03:00
|
|
|
|
2024-11-16 17:49:55 +03:00
|
|
|
const message = {
|
|
|
|
type: 'set-theme',
|
|
|
|
theme: newTheme
|
|
|
|
};
|
2021-12-11 12:24:08 +03:00
|
|
|
|
2024-11-16 17:49:55 +03:00
|
|
|
const utterances = document.querySelector('.utterances-frame').contentWindow;
|
|
|
|
utterances.postMessage(message, origin);
|
|
|
|
}
|
2021-12-11 12:24:08 +03:00
|
|
|
});
|
2023-09-14 20:24:13 +03:00
|
|
|
})();
|
2021-12-11 12:24:08 +03:00
|
|
|
</script>
|