hugo-theme-stack-stars/layouts/partials/comments/provider/cusdis.html
Hue 25581cc446
fix(comments/cusdis): use the correct script for the self-hosted version (#403)
* Modify the Self-hosting js source path

* refactor(comments/cusdis): avoid multiple if statement

Co-authored-by: Jimmy Cai <github@jimmycai.com>
2021-10-31 10:15:57 +01:00

21 lines
679 B
HTML

{{- $host := default "https://cusdis.com" .Site.Params.comments.cusdis.host -}}
<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>
<script async defer src="{{ $host }}/js/cusdis.es.js"></script>
<script>
function setCusdisTheme(theme) {
let cusdis = document.querySelector('#cusdis_thread iframe');
if (cusdis) {
window.CUSDIS.setTheme(theme)
}
}
window.addEventListener('onColorSchemeChange', (e) => {
setCusdisTheme(e.detail)
})
</script>