← hugo-clarity

Added support for Utterances labeling.

c703dc4f083e495ad641dbf3fd5be4b9df774491 · Neven Cvetkovic · Apr 11, 2023 19:13

All blog posts created by Utterances will be labeled with a custom pre-defined label. The label needs to be manually added to your Github repository Issues labels.

See more details in Utterances documentation:
https://utteranc.es/#heading-issue-label

Signed-off-by: Neven Cvetkovic <ncvetkovic@vmware.com>

+6 −1 · 3 files changed

  • README.md +1 −0
  • exampleSite/config/_default/params.toml +2 −1
  • layouts/partials/utterances.html +3 −0
diff --git a/README.md b/README.md
index ca61c24..c84501d 100644
--- a/README.md
+++ b/README.md
@@ -820,6 +820,7 @@ You can override these setting from each post individually. For example, you may
  * Comment out the line for `disqusShortname = ""` in the `/config/_default/config.toml` file.
  * Set `comments = true` in the `/config/_default/params.toml` file.
  * Configure the utterances parameters in the `/config/_default/params.toml` file.
+ * Optionally, you can choose a label that will be assigned to all issues created by Utterances. The label must exist in your Github repository, as Utterances cannot attach labels that do not exist. Configure `utterancesLabel` parameter in `/config/_default/params.toml` file, after you have added a label to your Github repository Issues labels. Labels are case sensitive and support Emoji in label names. ✨💬✨
 
  Utterances is loaded in the `comments.html` partial by referring to the `utterances.html` partial.   Since `single.html` layout loads comments if comments are enabled, you must ensure *both* the `comments` and `utterances` parameters are configured.
 
diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml
index 8704375..6557453 100644
--- a/exampleSite/config/_default/params.toml
+++ b/exampleSite/config/_default/params.toml
@@ -103,8 +103,9 @@ languageMenuName = "🌐"
 # comments = false
 
 # Enable or disable Utterances (https://github.com/utterance/utterances) Github Issue-Based Commenting
-# utterances = true  #Run the utterances script in the single.html layout to load https://utteranc.es comments
+# utterances = true  # Run the utterances script in the single.html layout to load https://utteranc.es comments
 # utterancesRepo = "GHUsername/Repository.Name" # Utterances is enabled when this param is set
+# utterancesLabel = "blog comments ✨💬✨" # The label needs to be manually added to your Github repository issues before configuring here
 # utterancesTheme = "github-light" # Default: github-dark
 # utterancesIssueTerm = "pathname" # Default: pathname
 
diff --git a/layouts/partials/utterances.html b/layouts/partials/utterances.html
index 280c291..8261e0b 100644
--- a/layouts/partials/utterances.html
+++ b/layouts/partials/utterances.html
@@ -3,6 +3,9 @@
          repo="{{.Site.Params.utterancesRepo}}"
          issue-term="{{.Site.Params.utterancesIssueTerm | default "pathname"}}"
          theme="{{.Site.Params.utterancesTheme | default "github-dark"}}"
+         {{ if .Site.Params.utterancesLabel }}
+         label="{{.Site.Params.utterancesLabel | default "comments"}}"
+         {{ end }}
          crossorigin="anonymous"
          async>
  </script>