无法在Jekyll博客中加载多个评论系统

时间:2018-12-21 12:10:24

标签: jekyll

我试图在jekyll博客中实现针对不同类别的disqus和facebook评论系统。

这是我目前的做法。

     
  {% for category in site.categories %}

  {% if category.type == "personal" %}

  {% include facebook.html %}

  {% else %}

  {% include disqus.html %}

  {% endif %}

  {% endfor %}

Expected result: Facebook注释应从facebook.html的类别personal中加载,否则disqus注释应在所有其他类别中加载。

Actual result: Disqus评论将自动加载到个人类别中,而与循环无关。

应该进行哪些更改才能正确加载评论?

2 个答案:

答案 0 :(得分:2)

您似乎希望根据“个人”类别的存在在每页上打印Disqus或Facebook。

正如@marcanuy所说,您必须引用page.categories,它是一个数组。

{% if page.categories contains "personnal" %}
  {% include facebook.html %}
{% else %}
  {% include disqus.html %}
{% endif %}

答案 1 :(得分:0)

类别没有type属性。直接检查:

  {% for category in page.categories %}

  {% if category == "personal" %}

  {% include facebook.html %}

  {% else %}

  {% include disqus.html %}

  {% endif %}

  {% endfor %}

应检测个人类别并加载 disqus 评论。

相关问题