diff options
author | 安红豆 <55517494+ormissia@users.noreply.github.com> | 2021-11-18 20:17:46 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-18 20:17:46 +0300 |
commit | 4e029b7de8fc432012f2279e4bcbe65727e4f055 (patch) | |
tree | 8566544ed2911dab3e000ca7b8801eb23641c83e | |
parent | 3cd9c910f72a67c564836abc13e3bd6b2aa91336 (diff) |
Add utteranc comment plugin (#465)v3.3.0
* add comment plugin utteranc(save message to github issue)
config.yml
# Enable comment feature. There, should be only one of them.
comment:
enable: true
utteranc:
repo: ormissia/ormissia.github.io
issueTerm: title
theme: github-light
* Update utteranc.html
-rw-r--r-- | layouts/_default/single.html | 3 | ||||
-rw-r--r-- | layouts/partials/utteranc.html | 22 |
2 files changed, 25 insertions, 0 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 2423a98..633fe1f 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -165,6 +165,9 @@ <!-- Add valine --> {{ else if .valine }} {{ partial "valine.html" . }} + <!-- Add utteranc --> + {{ else if .utteranc }} + {{ partial "utteranc.html" . }} {{ end }} {{ end }} {{ end }} diff --git a/layouts/partials/utteranc.html b/layouts/partials/utteranc.html new file mode 100644 index 0000000..0bbaaad --- /dev/null +++ b/layouts/partials/utteranc.html @@ -0,0 +1,22 @@ +{{ $repo := site.Params.features.comment.utteranc.repo }} +{{ $issueTerm := site.Params.features.comment.utteranc.issueTerm }} +{{ $theme := site.Params.features.comment.utteranc.theme }} + +<div id="utteranc_thread"></div> +<div id="comments" class="comments"> + <div id="comments-container"></div> +</div> +<script type="text/javascript"> + (function() { + var utterances = document.createElement('script'); + utterances.type = 'text/javascript'; + utterances.async = true; + utterances.setAttribute('repo','{{ $repo }}') + utterances.setAttribute('issue-term','{{ $issueTerm }}') + utterances.setAttribute('theme','{{ $theme }}') + utterances.crossorigin = 'anonymous'; + utterances.src = 'https://utteranc.es/client.js'; + + document.getElementById('comments-container').appendChild(utterances); + })(); +</script> |