Add disqus comment (#79)

* add disqus

* Add readme

---------

Co-authored-by: adibaulia <adib.aulia@gli.id>
This commit is contained in:
adibaulia 2023-04-08 10:49:51 +07:00 committed by GitHub
parent 3fa25abce4
commit d717302b01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 0 deletions

View file

@ -17,6 +17,7 @@ Forked from [Ezhil Theme](https://github.com/vividvilla/ezhil)
- Dark/Light Mode toggle - Dark/Light Mode toggle
- tl:dr; frontamatter - tl:dr; frontamatter
- Cache busting for CSS files - Cache busting for CSS files
- Disqus Comments
## Installation ## Installation
In your Hugo website directory, create a new folder named theme and clone the repo In your Hugo website directory, create a new folder named theme and clone the repo
@ -73,6 +74,8 @@ pygmentsstyle = "monokai"
pygmentscodefences = true pygmentscodefences = true
pygmentscodefencesguesssyntax = true pygmentscodefencesguesssyntax = true
disqusShortname = "yourDisqusShortname"
paginate=3 # articles per page paginate=3 # articles per page
[params] [params]

View file

@ -28,6 +28,15 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
</div> </div>
{{- $.Scratch.Set "isDisqus" true -}}
<!-- Check if disqus short name is given -->
{{ if not .Site.DisqusShortname }}
{{- $.Scratch.Set "isDisqus" false -}}
{{ end }}
{{- if eq ($.Scratch.Get "isDisqus") true -}}
{{- partial "disqus.html" . -}}
{{- end -}}
</article> </article>
</main> </main>
{{ end }} {{ end }}

View file

@ -0,0 +1,19 @@
<div id="disqus_thread"></div>
<script type="text/javascript">
(function () {
// Don't ever inject Disqus on localhost--it creates unwanted
// discussions from 'localhost:1313' on your Disqus account...
if (window.location.hostname == "localhost")
return;
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
var disqus_shortname = '{{ .Site.DisqusShortname }}';
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by
Disqus.</a></noscript>
<a href="http://disqus.com/" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>