From d717302b0163e4fbe4511cb5473d87334734b037 Mon Sep 17 00:00:00 2001 From: adibaulia Date: Sat, 8 Apr 2023 10:49:51 +0700 Subject: [PATCH] Add disqus comment (#79) * add disqus * Add readme --------- Co-authored-by: adibaulia --- README.md | 3 +++ layouts/_default/single.html | 9 +++++++++ layouts/partials/disqus.html | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 layouts/partials/disqus.html diff --git a/README.md b/README.md index 9da1ad9..a2aef29 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Forked from [Ezhil Theme](https://github.com/vividvilla/ezhil) - Dark/Light Mode toggle - tl:dr; frontamatter - Cache busting for CSS files +- Disqus Comments ## Installation In your Hugo website directory, create a new folder named theme and clone the repo @@ -73,6 +74,8 @@ pygmentsstyle = "monokai" pygmentscodefences = true pygmentscodefencesguesssyntax = true +disqusShortname = "yourDisqusShortname" + paginate=3 # articles per page [params] diff --git a/layouts/_default/single.html b/layouts/_default/single.html index e072801..0e96234 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -28,6 +28,15 @@ {{ end }} {{ end }} + {{- $.Scratch.Set "isDisqus" true -}} + + {{ if not .Site.DisqusShortname }} + {{- $.Scratch.Set "isDisqus" false -}} + {{ end }} + + {{- if eq ($.Scratch.Get "isDisqus") true -}} + {{- partial "disqus.html" . -}} + {{- end -}} {{ end }} diff --git a/layouts/partials/disqus.html b/layouts/partials/disqus.html new file mode 100644 index 0000000..11bd488 --- /dev/null +++ b/layouts/partials/disqus.html @@ -0,0 +1,19 @@ +
+ + +comments powered by Disqus \ No newline at end of file