Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support custom issue-term for utterances #443

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ commento = false
[utterances] # https://utteranc.es/
owner = "" # Your GitHub ID
repo = "" # The repo to store comments
issueTerm = "" # Choose the mapping between blog posts and GitHub issues. pathname (default), title, url, og:title...

[gitalk] # Gitalk is a comment system based on GitHub issues. see https://github.com/gitalk/gitalk
owner = "" # Your GitHub ID
Expand Down
4 changes: 3 additions & 1 deletion layouts/partials/comments/utterances.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
var owner = JSON.parse({{ $owner | jsonify }});
{{ $repo:= .Site.Params.utterances.repo }}
var repo = JSON.parse({{ $repo | jsonify }});
{{ $issueTerm:= .Site.Params.utterances.issueTerm | default "pathname" }}
var issueTerm = JSON.parse({{ $issueTerm | jsonify }});
{{ $baseTheme:= index .Site.Params.themeOptions 0 }}
var baseTheme = JSON.parse({{ $baseTheme | jsonify }});
var localTheme = localStorage.getItem('theme');
var utterTheme = checkTheme(localTheme, baseTheme);
var myScript = document.createElement('script');
myScript.setAttribute('src', 'https://utteranc.es/client.js');
myScript.setAttribute('repo', `${owner}/${repo}`);
myScript.setAttribute('issue-term', 'pathname');
myScript.setAttribute('issue-term', issueTerm);
myScript.setAttribute('theme', utterTheme);
myScript.setAttribute('crossorigin', 'anonymous');
myScript.setAttribute('async', '');
Expand Down