Skip to content

Commit

Permalink
feat: gitalk comment
Browse files Browse the repository at this point in the history
  • Loading branch information
mousemin committed Jun 26, 2021
1 parent fa971e8 commit 92c37f1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ <h2>{{ i18n "comments" }}</h2>
</div>

{{- end -}}
{{- if .Site.Params.gitalk.repo -}}
<div id="fb_comments_container">
<h2>{{ i18n "comments" }}</h2>
{{ partial "comments/gitalk.html" . }}
</div>

{{- end -}}

{{ end }}
</div>
Expand Down
21 changes: 21 additions & 0 deletions layouts/partials/comments/gitalk.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div id="gitalk-container"></div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
<script>
const gitalk = new Gitalk({
clientID: '{{ .Site.Params.Gitalk.clientID }}',
clientSecret: '{{ .Site.Params.Gitalk.clientSecret }}',
repo: '{{ .Site.Params.Gitalk.repo }}',
owner: '{{ .Site.Params.Gitalk.owner }}',
admin: ['{{ .Site.Params.Gitalk.owner }}'],
id: location.pathname, // Ensure uniqueness and length less than 50
distractionFreeMode: false // Facebook-like distraction free mode
});
(function() {
if (["localhost", "127.0.0.1"].indexOf(window.location.hostname) != -1) {
document.getElementById('gitalk-container').innerHTML = 'Gitalk comments not available by default when the website is previewed locally.';
return;
}
gitalk.render('gitalk-container');
})();
</script>

0 comments on commit 92c37f1

Please sign in to comment.