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;
}
/* 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 */
.patterns-list {
list-style: none;

View File

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

View File

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

View File

@ -430,6 +430,20 @@ caption {
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 */
.patterns-list {
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>
</div>
{{ end }}
{{ if ne .Params.toc false }}
{{ partial "toc" . }}
{{ end }}
{{ .Content }}
</main>
{{ partial "disqus.html" . }}
{{ 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';
}