findcommonground.uk/_layouts/blog_by_category.html
2016-01-04 13:09:07 +01:00

37 lines
1.3 KiB
HTML

---
layout: default
---
<header id="post-header">
<h1 id="post-title">{{ page.category }}</h1>
<h4 id="post-subtitle">Articles by category</h4>
</header>
<div id="post-content">
{% if site.categories[page.category] %}
{% for post in site.categories[page.category] %}
{% capture post_year %}{{ post.date | date: '%Y' }}{% endcapture %}
{% if forloop.first %}
<h3>{{ post_year }}</h3><div class="list-group">
{% endif %}
{% if forloop.first == false %}
{% assign previous_index = forloop.index0 | minus: 1 %}
{% capture previous_post_year %}{{ site.categories[page.category][previous_index].date | date: '%Y' }}{% endcapture %}
{% if post_year != previous_post_year %}
</div><h3>{{ post_year }}</h3><div class="list-group">
{% endif %}
{% endif %}
<a href="{{ post.url }}/" class="list-group-item">
<h4 class="list-group-item-heading">{{ post.title }}</h4>
</a>
{% if forloop.last %}
</div>
{% endif %}
{% endfor %}
{% else %}
<p>There are no posts in this category.</p>
{% endif %}
</div>