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

Cannot load multiple commenting system in Jekyll blog

我正在尝试为 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 评论都会自动加载到个人类别中。

应该更改哪些内容才能正确加载评论?

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

  {% for category in page.categories %}

  {% if category == "personal" %}

  {% include facebook.html %}

  {% else %}

  {% include disqus.html %}

  {% endif %}

  {% endfor %}

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

您似乎想根据 "personnal" 类别的存在情况在每个页面上打印 disqus 或 facebook。

正如@marcanuy所说,你必须参考page.categories,这是一个数组。

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