diff options
author | Thibaud Lepretre <thibaud.lepretre@gmail.com> | 2020-03-31 00:11:06 +0300 |
---|---|---|
committer | Thibaud Lepretre <thibaud.lepretre@gmail.com> | 2021-08-11 15:02:36 +0300 |
commit | cd2ca365492f40526232ad63bd1d1de93b0da525 (patch) | |
tree | d06112289bc8d8a61cce609c51d377f5e4922d37 | |
parent | f363e24cafe4b43f9484d651146b00860da7eb1a (diff) |
Comment systems
-rw-r--r-- | exampleSite/config.toml | 39 | ||||
-rw-r--r-- | layouts/_default/single.html | 6 | ||||
-rw-r--r-- | layouts/partials/head.html | 2 | ||||
-rw-r--r-- | layouts/partials/post/actions.html | 2 | ||||
-rw-r--r-- | layouts/partials/post/comment.html | 28 | ||||
-rw-r--r-- | layouts/partials/post/disqus.html | 3 | ||||
-rw-r--r-- | layouts/partials/script.html | 29 |
7 files changed, 53 insertions, 56 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 4cbe08e..0711b82 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -105,23 +105,7 @@ canonifyurls = true # ------------- # Customization # ------------- - [params] - # ------ - # Header - # ------ - # The link at the right of the header is customizable - # You can add a link (as an icon) at the right of the header instead of the author's gravatar image or author's picture. - # By default, author's gravatar or author's picture is displayed. - # url: /#search - # icon: search - # class: st-search-show-outputs - - [params.header.rightLink] - class = "" - icon = "" - url = "/#about" - # ----------- # Description # ----------- @@ -210,7 +194,6 @@ canonifyurls = true # Your favicon path, default is "/favicon.png" # favicon = "/favicon.png" - # ------------------ # External resources # ------------------ @@ -308,6 +291,28 @@ canonifyurls = true # Your Facebook app id used to connect your blog with your facebook app account (Facebook Insights). E.g : 9841307 # fbAppId = + # -------------- + # Comment system + # -------------- + [params.comment] + [params.comment.disqus] + enable = true + shortname = "hugo-tranquilpeak-theme" + + # -------------------- + # Header configuration + # -------------------- + # The link at the right of the header is customizable + # You can add a link (as an icon) at the right of the header instead of the author's gravatar image or author's picture. + # By default, author's gravatar or author's picture is displayed. + # url: /#search + # icon: search + # class: st-search-show-outputs + [params.header.rightLink] + class = "" + icon = "" + url = "/#about" + # -------------------- # Footer configuration # -------------------- diff --git a/layouts/_default/single.html b/layouts/_default/single.html index e8d4c34..19c55b8 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -34,11 +34,7 @@ {{ end }} {{ end }} {{ partial "post/actions.html" . }} - {{ if not (eq .Params.comments false) }} - {{ if .Site.DisqusShortname }} - {{ partial "post/disqus.html" . }} - {{ end }} - {{ end }} + {{ partial "post/comment.html" . }} </div> </article> {{ partial "footer.html" . }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 7334277..fd591db 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -56,7 +56,7 @@ {{ end }} {{ end }} - {{ if .Params.ga.async }} + {{ if or .Params.googleAnalytics.async .Params.ga.async }} {{ template "_internal/google_analytics_async.html" . }} {{ else }} {{ template "_internal/google_analytics.html" . }} diff --git a/layouts/partials/post/actions.html b/layouts/partials/post/actions.html index 909e9c4..e599dd9 100644 --- a/layouts/partials/post/actions.html +++ b/layouts/partials/post/actions.html @@ -62,7 +62,7 @@ </li> {{ end }} {{ end }} - {{ if and (not (eq .Params.comments false)) .Site.DisqusShortname }} + {{ if and (not (eq .Params.comment.disqus.enable false)) .Site.DisqusShortname }} <li class="post-action"> <a class="post-action-btn btn btn--default" href="#disqus_thread"> <i class="fa fa-comment-o"></i> diff --git a/layouts/partials/post/comment.html b/layouts/partials/post/comment.html new file mode 100644 index 0000000..b29c439 --- /dev/null +++ b/layouts/partials/post/comment.html @@ -0,0 +1,28 @@ +{{ if .IsPage }} + {{ if .Site.Params.comment.disqus.enable }} + <div id="disqus_thread"> + <noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> + </div> + <script type="text/javascript"> + var disqus_config = function() { + this.page.url = '{{ .Permalink }}'; + {{ if .Params.disqusIdentifier }} + this.page.identifier = '{{ .Params.disqusIdentifier }}'; + {{ else }} + this.page.identifier = '{{ .RelPermalink }}' + {{ end }} + }; + (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> + {{ end }} +{{ end }} diff --git a/layouts/partials/post/disqus.html b/layouts/partials/post/disqus.html deleted file mode 100644 index 4cf9229..0000000 --- a/layouts/partials/post/disqus.html +++ /dev/null @@ -1,3 +0,0 @@ -<div id="disqus_thread"> - <noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> -</div>
\ No newline at end of file diff --git a/layouts/partials/script.html b/layouts/partials/script.html index a7cd608..20c77da 100644 --- a/layouts/partials/script.html +++ b/layouts/partials/script.html @@ -30,35 +30,6 @@ $(document).ready(function() { }); </script> {{ end }} -{{ if .IsPage }} - {{ if not (eq .Params.comments false) }} - {{ if .Site.DisqusShortname }} - <script> - var disqus_config = function() { - this.page.url = '{{ .Permalink }}'; - {{ if .Params.disqusIdentifier }} - this.page.identifier = '{{ .Params.disqusIdentifier }}'; - {{ else }} - this.page.identifier = '{{ .RelPermalink }}' - {{ end }} - }; - (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 d = document, s = d.createElement('script'); - var disqus_shortname = '{{ .Site.DisqusShortname }}'; - s.src = '//' + disqus_shortname + '.disqus.com/embed.js'; - - s.setAttribute('data-timestamp', +new Date()); - (d.head || d.body).appendChild(s); - })(); - </script> - {{ end }} - {{ end }} -{{ end }} {{ if or .Params.math .Site.Params.math }} <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_CHTML-full" integrity="sha256-GhM+5JHb6QUzOQPXSJLEWP7R73CbkisjzK5Eyij4U9w=" crossorigin="anonymous"></script> <script type="text/x-mathjax-config"> |