mirror of https://github.com/luizdepra/hugo-coder.git

Sammy
24.39.2024 943d8597b5aa37f3ee23905c5c85e2ca4f0ed455
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{{- 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 -}}