Skip to content

Commit

Permalink
feat(comments): add Gitalk support (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cookiekira authored Sep 18, 2021
1 parent 00c8616 commit 66bd8a2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions exampleSite/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ params:
reactionsEnabled: 1
emitMetadata: 0

gitalk:
owner:
admin:
repo:
clientID:
clientSecret:

widgets:
enabled:
- search
Expand Down
30 changes: 30 additions & 0 deletions layouts/partials/comments/provider/gitalk.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- with .Site.Params.comments.gitalk -}}
<div id="gitalk-container"></div>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/gitalk.css"
/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gitalk.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/js/md5.min.js"></script>
<script>
const gitalk = new Gitalk({
clientID: "{{- .clientID -}}",
clientSecret: "{{- .clientSecret -}}",
repo: "{{- .repo -}}",
owner: "{{- .owner -}}",
admin: ["{{- .admin -}}"],
distractionFreeMode: false, // Facebook-like distraction free mode
id: md5(location.pathname), // Max Location.pathname Legth:75 https://github.com/gitalk/gitalk/issues/102
});
(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>
{{ end }}

0 comments on commit 66bd8a2

Please sign in to comment.