Reputation: 138
I am trying to implement disqus and facebook commenting system for different categories in jekyll blog.
Here is my current approach.
{% for category in site.categories %}
{% if category.type == "personal" %}
{% include facebook.html %}
{% else %}
{% include disqus.html %}
{% endif %}
{% endfor %}
Expected result:
Facebook comment should be loaded in category personal
from facebook.html otherwise disqus comment should be loaded in all other category.
Actual result:
Disqus comments loads automatically in personal category regardless of the loop.
What should be changed to make the comments load correctly?
Upvotes: 0
Views: 58
Reputation: 23972
Category doesn't have a type
attribute. Checking directly like:
{% for category in page.categories %}
{% if category == "personal" %}
{% include facebook.html %}
{% else %}
{% include disqus.html %}
{% endif %}
{% endfor %}
Should detect the personal category and load disqus comments.
Upvotes: 0
Reputation: 52819
It seems that you want to print disqus or facebook on each page depending on "personnal" category presence.
As @marcanuy says, you have to refer to page.categories
, which is an array.
{% if page.categories contains "personnal" %}
{% include facebook.html %}
{% else %}
{% include disqus.html %}
{% endif %}
Upvotes: 2