Skip to content

Commit

Permalink
Add support to Disqus feature (yousinix#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
rribeiro1 authored Apr 27, 2020
1 parent 20ffd28 commit ce60478
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
14 changes: 14 additions & 0 deletions _includes/blog/disqus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{%- if site.disqus -%}
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = '{{ site.disqus }}';
(function() {
var disqus = document.createElement('script');
disqus.type = 'text/javascript';
disqus.async = true;
disqus.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(disqus);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
{%- endif -%}
6 changes: 6 additions & 0 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ <h1><b>{{ page.title }}</b></h1>
</p>

{{ content }}

{% if page.comments %}
<div class="pt-5">
{% include blog/disqus.html %}
</div>
{% endif %}
10 changes: 9 additions & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ collections:
output: true # For Documentation Only


### Disqus ###
disqus: your-short-name-disqus # Your website Shortname on disqus


### Defaults for collections ###
defaults:
- scope:
Expand All @@ -70,7 +74,11 @@ defaults:
type: "elements" # For Documentation Only
values: # For Documentation Only
layout: "element" # For Documentation Only

- scope:
path: ""
type: "posts"
values:
comments: false # Set to true to enable disqus comments

### Exclude from processing ###
exclude:
Expand Down
7 changes: 6 additions & 1 deletion test/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ author:

### Posts ###
permalink: /blog/:title
disqus: short-name-disqus


### Collections ###
Expand All @@ -46,7 +47,11 @@ defaults:
type: "elements"
values:
layout: "element"

- scope:
path: ""
type: "posts"
values:
comments: false

plugins:
- jekyll-default-layout
Expand Down

0 comments on commit ce60478

Please sign in to comment.