Skip to content

Commit

Permalink
Add disqus comment to this theme.
Browse files Browse the repository at this point in the history
Signed-off-by: Tao He <sighingnow@gmail.com>
  • Loading branch information
sighingnow committed Mar 19, 2023
1 parent 6006e3a commit 9bd8539
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ tracker:
application_insights: "<YOUR APPLICATION INSIGHTS CONNECTION STRING>"
```

## Disqus comments

[Disqus](https://disqus.com/) comments can be enabled by adding the following configuration in `_config.yaml`:

```yaml
disqushandler: "<YOUR DISQUS SHORTNAME>"
```

## Extra StyleSheet or Javascript elements

You can add extra CSS or JavaScript references using configuration collections:
Expand Down
7 changes: 5 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ kramdown:

syntax_highlighter_style: colorful

markdown_ext: markdown,mkdown,mkdn,mkd,md
markdown_ext: markdown,mkdown,mkdn,mkd,md

# Permalinks
permalink: /:categories/:year-:month-:day-:title:output_ext
permalink: /:categories/:year-:month-:day-:title:output_ext

# Disqus comments
# disqushandler: sighingnow

exclude:
- _drafts
Expand Down
4 changes: 4 additions & 0 deletions _includes/body.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ <h1 id="{{ page.id }}">{{ site.title | escape }}</h1>
{% endif %}

{{ content }}

{%- if jekyll.environment != 'dev' and site.disqushandler -%}
{%- include disqus.html -%}
{%- endif -%}
</section>
</div>

Expand Down
19 changes: 19 additions & 0 deletions _includes/disqus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% if site.disqushandler && page.disqus != false %}
<br/><br/><h3>Comments:</h3>
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = '{{ page.url | absolute_url }}';
this.page.identifier = '{{ page.url | absolute_url }}';
};

(function() {
var d = document, s = d.createElement('script');
s.src = 'https://{{ site.disqushandler }}.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>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
{% endif %}

0 comments on commit 9bd8539

Please sign in to comment.