From 9fcdedf0421bfd99c55d6e140e75c337d9e7c888 Mon Sep 17 00:00:00 2001
From: Jimmy Cai <jimmehcai@gmail.com>
Date: Sun, 4 Oct 2020 16:23:08 +0200
Subject: [PATCH] feat(comments): add utterances support

closes https://github.com/CaiJimmy/hugo-theme-stack/issues/21
---
 exampleSite/config.toml                          |  8 ++++++--
 .../partials/comments/provider/utterances.html   | 16 ++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 layouts/partials/comments/provider/utterances.html

diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 97df7bb..95dd067 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -28,8 +28,12 @@ DefaultContentLanguage = "en"                   # Theme i18n support
             default = "Licensed under CC BY-NC-SA 4.0"
     [params.comments]
         enabled = true
-        # Only Disqus is available so far
-        provider = "disqus"
+        provider = "disqus"         # Available: disqus, utterances    
+        [params.comments.utterances]
+            repo = ""
+            issueTerm = "pathname"
+            label = ""             # Optional
+            theme="preferred-color-scheme"
     [params.widgets]
         enabled = ['archives', 'tag-cloud']
         [params.widgets.archives]
diff --git a/layouts/partials/comments/provider/utterances.html b/layouts/partials/comments/provider/utterances.html
new file mode 100644
index 0000000..75d63ce
--- /dev/null
+++ b/layouts/partials/comments/provider/utterances.html
@@ -0,0 +1,16 @@
+<script src="https://utteranc.es/client.js" 
+        repo="{{ .Site.Params.comments.utterances.repo }}"
+        issue-term="{{ .Site.Params.comments.utterances.issueTerm }}"
+        theme="{{ .Site.Params.comments.utterances.theme }}" 
+        {{ with .Site.Params.comments.utterances.label }}
+        label="{{ . }}"
+        {{ end }}
+        crossorigin="anonymous" 
+        async>
+</script>
+
+<style>
+    .utterances {
+        max-width: unset;
+    }
+</style>
\ No newline at end of file