From 58913dcd56c199567bff009b943c26e5bd9d3fca Mon Sep 17 00:00:00 2001 From: Zachary Betz Date: Tue, 5 Mar 2019 14:59:47 -0600 Subject: [PATCH] Add disqus comments --- assets/css/template-styles.css | 17 +++++++++++++++++ exampleSite/config.toml | 1 + exampleSite/config.yaml | 1 + ...css_c2e18c145f3470d19843d012c882b388.content | 14 ++++++++++++++ layouts/partials/disqus.html | 13 +++++++++++++ layouts/post/single.html | 2 +- static/js/dom-scripts.js | 9 +++++++++ 7 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/disqus.html diff --git a/assets/css/template-styles.css b/assets/css/template-styles.css index c93466d..066e8d4 100644 --- a/assets/css/template-styles.css +++ b/assets/css/template-styles.css @@ -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; diff --git a/exampleSite/config.toml b/exampleSite/config.toml index c403196..1bd0698 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -4,6 +4,7 @@ defaultContentLanguage = "en" title = "Cupper" theme = "cupper-hugo-theme" googleAnalytics = "UA-123456789-1" +disqusShortname = "yourdiscussshortname" [taxonomies] tag = "tags" diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 0d7d7e0..b24cc8e 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -4,6 +4,7 @@ defaultContentLanguage: en title: Cupper theme: cupper-hugo-theme googleAnalytics: UA-123456789-1 +disqusShortname: yourdiscussshortname taxonomies: tag: tags diff --git a/exampleSite/resources/_gen/assets/css/css/template-styles.css_c2e18c145f3470d19843d012c882b388.content b/exampleSite/resources/_gen/assets/css/css/template-styles.css_c2e18c145f3470d19843d012c882b388.content index 801a8cb..7f8006f 100644 --- a/exampleSite/resources/_gen/assets/css/css/template-styles.css_c2e18c145f3470d19843d012c882b388.content +++ b/exampleSite/resources/_gen/assets/css/css/template-styles.css_c2e18c145f3470d19843d012c882b388.content @@ -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; diff --git a/layouts/partials/disqus.html b/layouts/partials/disqus.html new file mode 100644 index 0000000..19305cc --- /dev/null +++ b/layouts/partials/disqus.html @@ -0,0 +1,13 @@ +
+ {{ $ctx := . }} + {{ with .Site.DisqusShortname }} + +
+ {{ if eq . "yourdiscussshortname" }} +

Disqus comments are disabled.

+ {{ else }} + {{ template "_internal/disqus.html" $ctx }} + {{ end }} +
+ {{ end }} +
diff --git a/layouts/post/single.html b/layouts/post/single.html index 5b409be..3374cf4 100644 --- a/layouts/post/single.html +++ b/layouts/post/single.html @@ -26,10 +26,10 @@ {{ end }} - {{ if ne .Params.toc false }} {{ partial "toc" . }} {{ end }} {{ .Content }} + {{ partial "disqus.html" . }} {{ end }} diff --git a/static/js/dom-scripts.js b/static/js/dom-scripts.js index 5128836..cc5f5b8 100644 --- a/static/js/dom-scripts.js +++ b/static/js/dom-scripts.js @@ -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'; +}