Skip to content

Commit

Permalink
add Disqus (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmau111 committed Jul 21, 2022
1 parent f8bb2c7 commit e567834
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -119,6 +119,13 @@ image: "/images/mangoose.jpeg"


If you don't set anything then the theme display the default image "https://raw.githubusercontent.com/jmau111/hugo-theme-ava/main/images/default.jpeg".

## Comments

There's now a custom Disqus partial. Please be aware this is not the most privacy-focused solution on the market.

To enable it, edit the Site variable `disqus` in the `config.toml` and replace "xxxxxxx" by your Disqus handle. Otherwise, nothing will be loaded.

## TODO

A lot of stuff, including:
Expand Down
1 change: 1 addition & 0 deletions exampleSite/config.toml
Expand Up @@ -21,6 +21,7 @@ canonifyURLs = true
[params]
ga_id=""
mainSections = ["post"]
disqus = "xxxxxxx"


[params.meta_tags]
Expand Down
1 change: 1 addition & 0 deletions layouts/_default/baseof.html
Expand Up @@ -50,6 +50,7 @@
{{ end }}
<div class="content slide-invert">
{{- block "content" . }}{{ end }}
{{- block "comments" . }}{{ end }}
</div>
</article>
{{ end }}
Expand Down
12 changes: 12 additions & 0 deletions layouts/partials/disqus.html
@@ -0,0 +1,12 @@
<div id="disqus_thread"></div>
<script>
(function() {
if (window.location.hostname === "localhost")
return;

const dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
const disqus_shortname = '{{ .Site.Params.disqus }}';
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
6 changes: 6 additions & 0 deletions layouts/post/single.html
Expand Up @@ -7,4 +7,10 @@

{{- define "content" }}
{{ .Content }}
{{- end }}

{{- define "comments" }}
{{- if ne .Site.Params.disqus "xxxxxxx" }}
{{- partial "disqus" . }}
{{- end }}
{{- end }}

0 comments on commit e567834

Please sign in to comment.