Skip to content

Commit

Permalink
Add Disqus-integration
Browse files Browse the repository at this point in the history
Fixes #38
  • Loading branch information
haohanyang authored Sep 28, 2020
1 parent 950e6f6 commit c743559
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ Feel free to submit pull requests for other translations of Tale's texts.

[Hugo documentation for multilingual sites](//gohugo.io/content-management/multilingual/)

### Disqus
Tale supports Disqus integration, a comment system that empowers dynamic features to static websites. To install it, just add the key `disqusShortname` in your `config.toml`
``` toml
disqusShortname = "disqus-example"
```
Add the parameter `comments` in the front-matter of the pages where you want to allow comments
```
---
comments: true
---
```

### Custom summaries

Tale allows for writing the summary of your posts manually by setting the `summary` variable in the page frontmatter. If this variable is not set, the summary that Hugo automatically generates will be used.
Expand Down
1 change: 1 addition & 0 deletions assets/scss/tale.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
@import 'tale/layout';
@import 'tale/pagination';
@import 'tale/catalogue';
@import 'tale/disqus';
3 changes: 3 additions & 0 deletions assets/scss/tale/_disqus.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.article-discussion {
margin: 0;
}
22 changes: 22 additions & 0 deletions layouts/disqus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div id="disqus_thread"></div>
<script>

/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
var disqus_shortname = '{{ .Site.DisqusShortname }}';
s.src = 'https://' + disqus_shortname + '.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">comments powered by Disqus.</a></noscript>

5 changes: 5 additions & 0 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<footer>
{{ if and .Params.comments (gt (len .Site.DisqusShortname) 0) }}
<figure class="article-discussion">
{{ template "_internal/disqus.html" . }}
</figure>
{{ end }}
<span>
&copy; <time datetime="{{ now }}">{{ now.Format "2006" }}</time> {{ .Site.Author.name }}. {{ i18n "generator" | safeHTML }}
</span>
Expand Down

0 comments on commit c743559

Please sign in to comment.