【发布时间】:2012-03-02 09:22:10
【问题描述】:
我正在尝试执行以下操作。 我使用 Jekyll 创建帖子列表,并按类别排序(周一...周日) 我想让它们按时间顺序显示,但 Jekyll 按字母顺序排列。
可以用 Jekyll 对数组进行排序吗?
我在帖子 yaml 中添加了一个订单密钥,以镜像 monday = 1 ... sunday = 7
我正在尝试使用此顺序键对数组进行排序,但它不起作用。
{% for post in posts_collate %}
{% capture class %} {{ post.tags | first }} {% endcapture%}
{% capture club %} {{ post.tags | last }} {% endcapture%}
{% if forloop.first %}
<h2>our events</h2>
<h3>{{ class }} & {{ club }}</h3>
<dl>
{% endif %}
{% if post.rel == 'me' %}
<dt>{{ post.category | sort: 'order' }}</dt>
<dd> <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></dd>
{% endif %}
{% if forloop.last %}
</dl>
{% endif %}
{% endfor %}
而且我在大型谷歌机器中找不到任何信息,所以我不确定这是否可能。
【问题讨论】: