Skip to content

Commit

Permalink
Add utteranc comment plugin (#465)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ormissia authored Nov 18, 2021
1 parent 3cd9c91 commit 4e029b7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ <h1>{{ .Page.Title }}</h1>
<!-- Add valine -->
{{ else if .valine }}
{{ partial "valine.html" . }}
<!-- Add utteranc -->
{{ else if .utteranc }}
{{ partial "utteranc.html" . }}
{{ end }}
{{ end }}
{{ end }}
Expand Down
22 changes: 22 additions & 0 deletions layouts/partials/utteranc.html
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 4e029b7

Please sign in to comment.