我正在尝试在成分页面中显示与成分相关的食谱。该代码有效,但它输出所有配方,没有任何过滤器:
{% 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
---