基于 jekyll 中的嵌套属性循环过滤集合

时间:2021-02-24 23:41:12

标签: for-loop jekyll github-pages liquid

我正在尝试在成分页面中显示与成分相关的食谱。该代码有效,但它输出所有配方,没有任何过滤器:

{% assign recipe = site.recipes | where: "ingredients.item", "Cheese" %}
{% for related_recipe in recipe limit:3 %}
<p>Recipes that use Cheese</p>
<ul>
    <li>{{ related_recipe.name }}</li>
</ul>
{% endfor %}

样品成分降价:

---
name: Cheese
---

示例配方降价:

---
name: Cheese Risotto
ingredients:
  - item: Cheese
  - item: Rice
---

0 个答案:

没有答案