【发布时间】:2020-02-12 12:57:05
【问题描述】:
我有点难以理解如何使用 Jekyll 访问一些嵌套数据。我希望有人可以帮助我。我正在尝试访问 prototypes.yml 文件中的数据。它用于在仪表板上填充卡片。但是,当我运行循环时,什么都没有返回。我的猜测是我没有正确定位details,但最终我有点不知所措。
prototypes.yml
ios:
details:
-
category: "category"
title: "title"
desc: "desc"
author: "Sean"
update: "12 Feb 2020"
android:
details:
-
category: "category"
title: "title"
desc: "desc"
author: "Sean"
update: "12 Feb 2020"
HTML
{% for row in site.data.prototypes %}
{% for detail in row.details %}
<a href="{{ detail.permalink }}" class="c-card c-card--{{ detail.category }}">
<h2>{{ detail.title }}</h2>
<p>{{ detail.desc }}</p>
<span>{{ detail.update }}</span>
</a>
{% endfor %}
{% endfor %}
【问题讨论】: