Add disqus comments

This commit is contained in:
Zachary Betz 2019-03-05 14:59:47 -06:00
parent 67ba008385
commit 58913dcd56
7 changed files with 56 additions and 1 deletions

View File

@ -430,6 +430,23 @@ caption {
margin-top: 0.5rem; margin-top: 0.5rem;
} }
/* Disqus Comments */
#disqus-container {
font-size: 0.85rem;
border: 1px solid;
padding: 1.5rem;
}
#disqus-button {
width: 100%;
}
#disqus-comments {
display: none;
}
#disqus-comments,
#disqus-comments iframe {
max-height: 75vh !important;
}
/* Pattern lists */ /* Pattern lists */
.patterns-list { .patterns-list {
list-style: none; list-style: none;

View File

@ -4,6 +4,7 @@ defaultContentLanguage = "en"
title = "Cupper" title = "Cupper"
theme = "cupper-hugo-theme" theme = "cupper-hugo-theme"
googleAnalytics = "UA-123456789-1" googleAnalytics = "UA-123456789-1"
disqusShortname = "yourdiscussshortname"
[taxonomies] [taxonomies]
tag = "tags" tag = "tags"

View File

@ -4,6 +4,7 @@ defaultContentLanguage: en
title: Cupper title: Cupper
theme: cupper-hugo-theme theme: cupper-hugo-theme
googleAnalytics: UA-123456789-1 googleAnalytics: UA-123456789-1
disqusShortname: yourdiscussshortname
taxonomies: taxonomies:
tag: tags tag: tags

View File

@ -430,6 +430,20 @@ caption {
margin-top: 0.5rem; margin-top: 0.5rem;
} }
/* Disqus Comments */
#disqus-container {
font-size: 0.85rem;
border: 1px solid;
padding: 1.5rem;
max-height: 50vh !important;
}
#disqus-button {
width: 100%;
}
#disqus-comments {
display: none;
}
/* Pattern lists */ /* Pattern lists */
.patterns-list { .patterns-list {
list-style: none; list-style: none;

View File

@ -0,0 +1,13 @@
<div id="disqus-container">
{{ $ctx := . }}
{{ with .Site.DisqusShortname }}
<button id="disqus-button" onclick="showComments()">Show comments</button>
<div id="disqus-comments">
{{ if eq . "yourdiscussshortname" }}
<p>Disqus comments are disabled.</p>
{{ else }}
{{ template "_internal/disqus.html" $ctx }}
{{ end }}
</div>
{{ end }}
</div>

View File

@ -26,10 +26,10 @@
</ul> </ul>
</div> </div>
{{ end }} {{ end }}
{{ if ne .Params.toc false }} {{ if ne .Params.toc false }}
{{ partial "toc" . }} {{ partial "toc" . }}
{{ end }} {{ end }}
{{ .Content }} {{ .Content }}
</main> </main>
{{ partial "disqus.html" . }}
{{ end }} {{ end }}

View File

@ -131,3 +131,12 @@
} }
}); });
}()); }());
/* Disqus comments */
function showComments() {
var disqusButton = document.getElementById('disqus-button');
disqusButton.remove();
var disqusComments = document.getElementById('disqus-comments');
disqusComments.style.display = 'block';
}