From 64d4afb610afba9d2067838435d5301f26cea29c Mon Sep 17 00:00:00 2001 From: Mogeko Date: Tue, 14 Sep 2021 22:03:57 +0200 Subject: [PATCH 1/4] 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 --- layouts/partials/comments/utterances.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/layouts/partials/comments/utterances.html b/layouts/partials/comments/utterances.html index 16da7e75..eb52a711 100644 --- a/layouts/partials/comments/utterances.html +++ b/layouts/partials/comments/utterances.html @@ -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', ''); From 9bd967fd761efa8923fd192b44becb229afb64b5 Mon Sep 17 00:00:00 2001 From: Mogeko Date: Tue, 14 Sep 2021 22:17:41 +0200 Subject: [PATCH 2/4] fix: fix character constant "pathname" when setting default for the configuration item Params.utterances.issueTerm, "pathname" should be used. --- layouts/partials/comments/utterances.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/comments/utterances.html b/layouts/partials/comments/utterances.html index eb52a711..abea153c 100644 --- a/layouts/partials/comments/utterances.html +++ b/layouts/partials/comments/utterances.html @@ -21,7 +21,7 @@ var owner = JSON.parse({{ $owner | jsonify }}); {{ $repo:= .Site.Params.utterances.repo }} var repo = JSON.parse({{ $repo | jsonify }}); - {{ $issueTerm:= .Site.Params.utterances.issueTerm | default 'pathname' }} + {{ $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 }}); From 20bfa06e9e986012c26b2e5352811d04edf31bbd Mon Sep 17 00:00:00 2001 From: Mogeko Date: Tue, 14 Sep 2021 22:53:19 +0200 Subject: [PATCH 3/4] docs: update exampleSite --- exampleSite/config/_default/params.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 2d7b955f..8f633121 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -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 From da1873ae38ad5af69d812c2b9f91586f8c64936a Mon Sep 17 00:00:00 2001 From: Mogeko Date: Tue, 14 Sep 2021 23:31:54 +0200 Subject: [PATCH 4/4] Update exampleSite/config/_default/params.toml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marcin ZajÄ…czkowski <148013+szpak@users.noreply.github.com> --- exampleSite/config/_default/params.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 8f633121..6d7adb76 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -127,7 +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... + 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