如果您愿意的话,我正在对我网站上的所有帖子进行“存档”。我想收集一年中的所有帖子。然而,这段代码工作正常;我希望它生成<h2>2014</h2>
需要的时候。
基本上,如果年份是 2014 年,则渲染 <h2>2014</h2>
并制作一个 <ul>
该年份的所有帖子(包含期刊类别)。
如果有人知道任何.rb
按年份存档的插件,请告诉我!
<h2>2014</h2>
{% for post in site.categories.journal %}
{% capture year %}{{post.date | date: "%Y"}}{% endcapture %}
{% if year == "2014" %}
<ul class="posts-in-year">
<li><p><a href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a> — {{ post.date | date: "%B %d" }}</p></li>
</ul>
{% endif %}
{% endfor %}
关于什么:
{% for post in site.categories.journal %}
{% capture year %}{{post.date | date: "%Y"}}{% endcapture %}
{% if year == "2014" %}
<h2>{% year %}</h2>
<ul class="posts-in-year">
<li><p><a href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a> — {{ post.date | date: "%B %d" }}</p></li>
</ul>
{% endif %}
{% endfor %}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)