我需要在输出中按字母顺序排序的几个yml
文件中的名称。
我试图| sort: 'name'
在我的 for 循环中添加。我得到:
Liquid Exception: no implicit conversion of String into Integer in pages/index.html
样本_data/cat/example1.yml
name: "test1"
permalink: "/test"
twitter: "WIP"
facebook: "WIP"
web: "WIP"
我的测试/cat
文件夹中至少有 3 个 yml 文件。
示例包含文件
<div class="row">
{% for cat_hash in site.data.cat %}
{% assign cat = cat_hash[1] | sort: 'name' %}
<div class="col-6 col-12-narrower">
<section>
<header>
<a class="image featured" href="{{ cat.permalink }}" title="{{ cat.name }}"><h3>{{ cat.name }}</h3></a>
</header>
<p>{{ cat.web }}</p>
</section>
</div>
{% endfor %}
</div>
我已经阅读了几个有关此类问题的示例。只是不确定循环中的任何哈希结果是否回答了我的情况?