Update to current version
All checks were successful
Building & Deploying Website / Deploy-Website (push) Successful in 12s
All checks were successful
Building & Deploying Website / Deploy-Website (push) Successful in 12s
This commit is contained in:
32
themes/hugo-coder/layouts/_partials/posts/utterances.html
Normal file
32
themes/hugo-coder/layouts/_partials/posts/utterances.html
Normal file
@@ -0,0 +1,32 @@
|
||||
{{- if isset .Site.Params "utterances" -}}
|
||||
{{- if and (isset .Site.Params.utterances "repo") (not (eq .Site.Params.utterances.repo "" )) (eq (.Params.disableComments | default false) false) -}}
|
||||
<div class="comments">
|
||||
<script>
|
||||
|
||||
let getTheme = window.localStorage && window.localStorage.getItem("colorscheme");
|
||||
let themeInParams = '{{$.Site.Params.utterances.theme}}';
|
||||
|
||||
if (getTheme == null) {
|
||||
if (themeInParams !== '' && themeInParams !== 'auto') {
|
||||
getTheme = themeInParams;
|
||||
}
|
||||
else {
|
||||
getTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? "dark" : "light";
|
||||
}
|
||||
}
|
||||
|
||||
let theme = getTheme === 'dark' ? 'github-dark' : 'github-light';
|
||||
let s = document.createElement('script');
|
||||
s.src = 'https://utteranc.es/client.js';
|
||||
s.setAttribute('repo', '{{ .Site.Params.utterances.repo }}');
|
||||
s.setAttribute('issue-term', '{{ default "title" .Site.Params.utterances.issueTerm }}');
|
||||
s.setAttribute('theme', theme);
|
||||
s.setAttribute('crossorigin', 'anonymous');
|
||||
s.setAttribute('async', '');
|
||||
document.querySelector('div.comments').innerHTML = '';
|
||||
document.querySelector('div.comments').appendChild(s);
|
||||
|
||||
</script>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user