2022-02-12 00:25:04 +03:00
|
|
|
<!-- https://giscus.app/ -->
|
|
|
|
<script type="text/javascript">
|
2023-03-22 20:29:17 +03:00
|
|
|
(function () {
|
|
|
|
const origin = 'https://giscus.app';
|
|
|
|
const iframe = 'iframe.giscus-frame';
|
|
|
|
const lightTheme = 'light';
|
|
|
|
const darkTheme = 'dark_dimmed';
|
|
|
|
|
2022-02-12 00:25:04 +03:00
|
|
|
let initTheme = lightTheme;
|
2023-03-22 20:29:17 +03:00
|
|
|
const html = document.documentElement;
|
2022-02-12 00:25:04 +03:00
|
|
|
|
2023-03-22 20:29:17 +03:00
|
|
|
if (
|
|
|
|
(html.hasAttribute('data-mode') &&
|
|
|
|
html.getAttribute('data-mode') === 'dark') ||
|
|
|
|
(!html.hasAttribute('data-mode') &&
|
|
|
|
window.matchMedia('(prefers-color-scheme: dark)').matches)
|
|
|
|
) {
|
2022-02-12 00:25:04 +03:00
|
|
|
initTheme = darkTheme;
|
|
|
|
}
|
|
|
|
|
|
|
|
let giscusAttributes = {
|
2023-03-22 20:29:17 +03:00
|
|
|
src: 'https://giscus.app/client.js',
|
|
|
|
'data-repo': '{{ site.comments.giscus.repo}}',
|
|
|
|
'data-repo-id': '{{ site.comments.giscus.repo_id }}',
|
|
|
|
'data-category': '{{ site.comments.giscus.category }}',
|
|
|
|
'data-category-id': '{{ site.comments.giscus.category_id }}',
|
|
|
|
'data-mapping': '{{ site.comments.giscus.mapping | default: 'pathname' }}',
|
|
|
|
'data-reactions-enabled': '{{ site.comments.giscus.reactions_enabled | default: '1' }}',
|
|
|
|
'data-emit-metadata': '0',
|
|
|
|
'data-theme': initTheme,
|
|
|
|
'data-input-position': '{{ site.comments.giscus.input_position | default: 'bottom' }}',
|
|
|
|
'data-lang': '{{ site.comments.giscus.lang | default: lang }}',
|
2023-09-19 23:37:17 +03:00
|
|
|
'data-loading': 'lazy',
|
2023-03-22 20:29:17 +03:00
|
|
|
crossorigin: 'anonymous',
|
|
|
|
async: ''
|
2022-02-12 00:25:04 +03:00
|
|
|
};
|
|
|
|
|
2023-03-22 20:29:17 +03:00
|
|
|
let giscusScript = document.createElement('script');
|
|
|
|
Object.entries(giscusAttributes).forEach(([key, value]) =>
|
|
|
|
giscusScript.setAttribute(key, value)
|
|
|
|
);
|
|
|
|
document.getElementById('tail-wrapper').appendChild(giscusScript);
|
2022-02-12 00:25:04 +03:00
|
|
|
|
2023-03-22 20:29:17 +03:00
|
|
|
addEventListener('message', (event) => {
|
|
|
|
if (
|
|
|
|
event.source === window &&
|
|
|
|
event.data &&
|
|
|
|
event.data.direction === ModeToggle.ID
|
|
|
|
) {
|
2022-02-12 00:25:04 +03:00
|
|
|
/* global theme mode changed */
|
|
|
|
const mode = event.data.message;
|
2023-03-22 20:29:17 +03:00
|
|
|
const theme = mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme;
|
2022-02-12 00:25:04 +03:00
|
|
|
|
|
|
|
const message = {
|
|
|
|
setConfig: {
|
|
|
|
theme: theme
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const giscus = document.querySelector(iframe).contentWindow;
|
|
|
|
giscus.postMessage({ giscus: message }, origin);
|
|
|
|
}
|
|
|
|
});
|
2023-03-22 20:29:17 +03:00
|
|
|
})();
|
2022-02-12 00:25:04 +03:00
|
|
|
</script>
|