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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
{{- $src := partial "utils/lib.html" (dict "$" . "type" "gitalk") -}}
{{- $srcCSS := partial "utils/lib.html" (dict "$" . "type" "gitalk-css") -}}
<link rel="stylesheet" href="{{ $srcCSS }}">
<script>
function loadComments() {
if (!document.getElementById('gitalk-container')) {
return;
}
if (typeof Gitalk === 'undefined') {
const getScript = (options) => {
const script = document.createElement('script');
script.defer = true;
script.crossOrigin = 'anonymous';
Object.keys(options).forEach((key) => {
script[key] = options[key];
});
document.body.appendChild(script);
};
getScript({
src: '{{ $src }}',
onload: () => {
newGitalk();
}
});
} else {
newGitalk();
}
}
function newGitalk() {
const gitalk = new Gitalk({
clientID: {{ .Site.Params.gitalkClientID }},
clientSecret: {{ .Site.Params.gitalkClientSecret }},
repo: {{ .Site.Params.gitalkRepo }},
owner: {{ .Site.Params.gitalkOwner }},
admin: {{ .Site.Params.gitalkAdmin }},
labels: {{ .Site.Params.gitalkLable }},
distractionFreeMode: {{ .Site.Params.gitalkDistractionFreeMode }},
perPage: {{ .Site.Params.gitalkPerPage }},
language: {{ .Site.Params.gitalkLanguage }},
pagerDirection: {{ .Site.Params.gitalkPagerDirection }},
createIssueManually: {{ .Site.Params.gitalkDistractionFreeMode }},
proxy: {{ .Site.Params.gitalkProxy }},
enableHotKey: {{ .Site.Params.gitalkEnableHotKey }},
id: location.pathname
})
gitalk.render('gitalk-container')
}
</script>
|