diff options
author | Cookiekira <42908926+Cookiekira@users.noreply.github.com> | 2021-09-18 11:03:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-18 11:03:08 +0300 |
commit | 66bd8a299798b53c78fa4b6b65c5c7256485a029 (patch) | |
tree | 0aa2c6ef6762c68081e956129911167a59ceb62c | |
parent | 00c8616931ae16fa499bd07e3a93dd7f6028000f (diff) |
feat(comments): add Gitalk support (#351)
-rw-r--r-- | exampleSite/config.yaml | 7 | ||||
-rw-r--r-- | layouts/partials/comments/provider/gitalk.html | 30 |
2 files changed, 37 insertions, 0 deletions
diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 9c17e9d..8139fa4 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -111,6 +111,13 @@ params: reactionsEnabled: 1 emitMetadata: 0 + gitalk: + owner: + admin: + repo: + clientID: + clientSecret: + widgets: enabled: - search diff --git a/layouts/partials/comments/provider/gitalk.html b/layouts/partials/comments/provider/gitalk.html new file mode 100644 index 0000000..95ca133 --- /dev/null +++ b/layouts/partials/comments/provider/gitalk.html @@ -0,0 +1,30 @@ +{{- with .Site.Params.comments.gitalk -}} +<div id="gitalk-container"></div> +<link + rel="stylesheet" + href="https://cdn.jsdelivr.net/npm/gitalk@1.7.2/dist/gitalk.css" +/> +<script src="https://cdn.jsdelivr.net/npm/gitalk@1.7.2/dist/gitalk.min.js"></script> +<script src="https://cdn.jsdelivr.net/npm/blueimp-md5@2.18.0/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 }} |