mirror of
https://github.com/13hannes11/hugo-coder-timeline.git
synced 2024-09-04 00:50:58 +02:00
dynamic change utterances theme with coder theme (#676)
* dynamic change utterances theme with coder theme * add myself into CONTRIBUTORS.md
This commit is contained in:
@@ -1,12 +1,24 @@
|
||||
{{- if isset .Site.Params "utterances" -}}
|
||||
{{- if and (isset .Site.Params.utterances "repo") (not (eq .Site.Params.utterances.repo "" )) (eq (.Params.disableComments | default false) false) -}}
|
||||
<script src="https://utteranc.es/client.js"
|
||||
repo= "{{ .Site.Params.utterances.repo }}"
|
||||
issue-term="{{ default "title" .Site.Params.utterances.issueTerm }}"
|
||||
{{ if isset .Site.Params.utterances "label" }}label="{{ .Site.Params.utterances.label }}"{{ end }}
|
||||
theme="{{ default "github-light" .Site.Params.utterances.theme }}"
|
||||
crossorigin="anonymous"
|
||||
async>
|
||||
</script>
|
||||
<div class="comments">
|
||||
<script>
|
||||
|
||||
let getTheme = window.localStorage && window.localStorage.getItem("colorscheme");
|
||||
|
||||
getTheme = getTheme == null ? '{{$.Site.Params.utterances.theme}}' : getTheme;
|
||||
|
||||
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