Files
site/layouts/partials/comments/utterances.html
2024-01-02 00:36:41 -05:00

24 lines
1.0 KiB
HTML

{{- $scriptSrc := "https://utteranc.es/client.js" -}}
{{- $issueTerm := .Page.Site.Params.comments.utterances.issueTerm -}}
{{- $label := .Page.Site.Params.comments.utterances.label -}}
{{- $username := .Page.Site.Params.comments.utterances.github.username -}}
{{- $repository := .Page.Site.Params.comments.utterances.github.repository -}}
<script>
// load utteranc comment
var getTheme = window.localStorage && window.localStorage.getItem("theme-storage");
getTheme = getTheme == null ? 'light' : getTheme;
let theme = getTheme === 'dark' ? 'github-dark' : 'github-light';
let s = document.createElement('script');
s.src = 'https://utteranc.es/client.js';
s.setAttribute('repo', '{{ print $username "/" $repository }}');
s.setAttribute('issue-term', '{{ $issueTerm }}');
s.setAttribute('theme', theme);
s.setAttribute('crossorigin', 'anonymous');
s.setAttribute('async', '');
document.querySelector('div.comments').innerHTML = '';
document.querySelector('div.comments').appendChild(s);
</script>