findcommonground.uk/_layouts/post_by_tag.html

44 lines
1.3 KiB
HTML

---
layout: default
---
<article class="page">
<h1>{{page.title}}</h1>
<p class='info'>
<span>Articles by tag</span>
</p>
<hr/>
<div id="post-content">
{% if site.tags[page.tag] %}
{% for post in site.tags[page.tag] %}
{% capture post_year %}{{ post.date | date: '%Y' }}{% endcapture %}
{% if forloop.first %}
<h3>{{ post_year }}</h3><ul>
{% endif %}
{% if forloop.first == false %}
{% assign previous_index = forloop.index0 | minus: 1 %}
{% capture previous_post_year %}{{ site.tags[page.tag][previous_index].date | date: '%Y' }}{% endcapture %}
{% if post_year != previous_post_year %}
</div><h3>{{ post_year }}</h3><div class="list-group">
{% endif %}
{% endif %}
<li>
<a href="{{ post.url }}/" class="read-more">
{{ post.title }}
</a>
</li>
{% if forloop.last %}
</ul>
{% endif %}
{% endfor %}
{% else %}
<p>There are no posts for this tag.</p>
{% endif %}
</div>
</article>