feat: support custom issue-term for utterances

Add a configuration item Params.utterances.issueTerm to choose the mapping between blog posts and GitHub issues, its default value is pathname
see https://utteranc.es
This commit is contained in:
Mogeko 2021-09-14 22:03:57 +02:00
parent 01f9e43e59
commit 64d4afb610
No known key found for this signature in database
GPG Key ID: B35485A88F40AD2C
1 changed files with 3 additions and 1 deletions

View File

@ -21,6 +21,8 @@
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');
@ -28,7 +30,7 @@
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', '');