diff options
author | Zhe Zhang <neomana@gmail.com> | 2016-01-31 04:51:08 +0300 |
---|---|---|
committer | Zhe Zhang <neomana@gmail.com> | 2016-01-31 04:51:08 +0300 |
commit | a491cb0d5d01970c83d81cd58cb204091d085ee3 (patch) | |
tree | 01f9411c6228e6b337d44dfd99c90fb5b4d113c5 | |
parent | 83b02fc03fb50940b209dda7c17060c27dc9963f (diff) |
integrate Disqus
-rw-r--r-- | README.md | 7 | ||||
-rw-r--r-- | layouts/post/single.html | 16 |
2 files changed, 23 insertions, 0 deletions
@@ -25,6 +25,7 @@ You could add `params` into your site's `config.toml` file: GithubID = "Your Github ID" TwitterID = "Your Twitter ID" AnalyticsID = "Your Google Analytics tracking code" + DisqusShortname = "Your Disqus shortname" Summary = true # takes true or false Content = false # takes true or false # if both are set to true, summary is shown. @@ -38,11 +39,17 @@ params: GithubID: "Your Github ID" TwitterID: "Your Twitter ID" AnalyticsID: "Your Google Analytics tracking code" + DisqusShortname: "Your Disqus shortname" Summary: true # takes true or false Content: false # takes true or false # if both are set to true, summary is shown ``` +### Enable Disqus to your post + +1. Add your Disqus Shortname to the site config file; +2. You can enable Disqus per-post, by adding `comments: true` (YAML) or `comments = true` (TOML) in the front matter of your post. To disable it, you can either change the value to `false` or just not include `comments` variable and its value at all. + ## Build your site ``` diff --git a/layouts/post/single.html b/layouts/post/single.html index 479555f..8f54087 100644 --- a/layouts/post/single.html +++ b/layouts/post/single.html @@ -23,6 +23,22 @@ </div> </div> </div> + {{ if .Params.comments }} + <div id="disqus_thread"></div> + <script> + var disqus_config = function () { + this.page.url = {{ .Permalink }}; + // this.page.identifier = PAGE_IDENTIFIER; + }; + (function() { + var d = document, s = d.createElement('script'); + s.src = '//{{ .Site.Params.DisqusShortname }}.disqus.com/embed.js'; + s.setAttribute('data-timestamp', +new Date()); + (d.head || d.body).appendChild(s); + })(); + </script> + <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript> + {{ end }} {{ partial "footer.html" . }} </div> <script src="{{ .Site.BaseURL }}/js/slim.js"></script> |