2026-01-26 15:50:18 +01:00
|
|
|
{{- $host := .Site.Params.comments.cusdis.host -}}
|
2025-12-22 03:55:09 +08:00
|
|
|
<div id="cusdis_thread" data-host="{{ $host }}" data-app-id="{{ .Site.Params.comments.cusdis.id }}"
|
|
|
|
|
data-page-id="{{ .File.UniqueID }}" data-page-url="{{ .Permalink }}" data-page-title="{{ .Title }}"></div>
|
2021-10-31 17:15:57 +08:00
|
|
|
<script async defer src="{{ $host }}/js/cusdis.es.js"></script>
|
2021-10-01 22:38:37 +08:00
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
function setCusdisTheme(theme) {
|
|
|
|
|
let cusdis = document.querySelector('#cusdis_thread iframe');
|
|
|
|
|
if (cusdis) {
|
2025-12-22 03:55:09 +08:00
|
|
|
window.CUSDIS.setTheme(theme);
|
|
|
|
|
cusdis.contentWindow.document.body.style.backgroundColor = window.getComputedStyle(document.body).backgroundColor;
|
2021-10-01 22:38:37 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-12-22 03:55:09 +08:00
|
|
|
window.addEventListener('load', function () {
|
|
|
|
|
let iframe = document.querySelector("#cusdis_thread iframe");
|
|
|
|
|
if (iframe) {
|
|
|
|
|
let observer = new MutationObserver(() => {
|
|
|
|
|
let scrollHeight = iframe.contentWindow.document.body.scrollHeight;
|
|
|
|
|
iframe.style.height = scrollHeight + "px";
|
|
|
|
|
});
|
|
|
|
|
observer.observe(iframe.contentWindow.document.body, { childList: true, subtree: true });
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-10-01 22:38:37 +08:00
|
|
|
window.addEventListener('onColorSchemeChange', (e) => {
|
|
|
|
|
setCusdisTheme(e.detail)
|
|
|
|
|
})
|
2025-12-22 03:55:09 +08:00
|
|
|
</script>
|