按年份获取Jekyllpost
如果您要访问我网站上的所有post,我正在制作“存档”。 我想收集一年的所有post。 但是,此代码工作正常; 我希望它在需要时生成
2014
。
基本上,如果年份是2014年,则渲染
2014
并在该年 给出所有post(带有期刊类别) 的
- 。
如果有人知道按年份存档的任何.rb
插件,请告诉我们!
2014
{% for post in site.categories.journal %} {% capture year %}{{post.date | date: "%Y"}}{% endcapture %} {% if year == "2014" %} {{ post.title }} — {{ post.date | date: "%B %d" }}
{% endif %} {% endfor %}
关于什么:
{% for post in site.categories.journal %} {% capture year %}{{post.date | date: "%Y"}}{% endcapture %} {% if year == "2014" %} {% year %}
{{ post.title }} — {{ post.date | date: "%B %d" }}
{% endif %} {% endfor %}
您可以在post中添加年份字段,然后再添加
2014
{% for post in (site.categories.journal | where: "year","2014" | sort: 'date') %} {{ post.title }} — {{ post.date | date: "%B %d" }}
{% endfor %}
2014
{% for post in site.categories.journal %} {% capture year %}{{post.date | date: "%Y"}}{% endcapture %} {% if year == "2014" %} {{ post.title }} — {{ post.date | date: "%B %d" }}
{% endif %} {% endfor %}