【发布时间】:2014-06-02 22:29:51
【问题描述】:
我想在我的 Jekyll 网站上为多个类别和语言提供多个后索引(索引?),这意味着多个条件。
我的帖子有 YAML 前端,包括:
categories:
- research
- blog
lang: en
现在我想要一个帖子索引,因为所有的研究帖子都是英文的。
我能做到:
{% for post in site.posts %}
{% if post.lang == 'en' and post.categories contains 'research' %}
{{ post.title }}
{% endif %}
{% endfor %}
然而,这搞砸了限制和按年份排序等细节。为了限制帖子的数量(等),Jekyll 似乎仍在查看整个帖子列表,不只是条件适用于谁。
这样的伪代码是理想的: {% for post in site.posts where post.lang == 'en' and post.categories contains 'research' %}
有什么想法吗?
Ps.:我不能使用任何插件;希望它与 GH Pages 兼容。 Pps.:我知道我可以使用语言作为一个类别,但感觉不对——这些是不同的信息。
【问题讨论】: