🐛 fix(archive): group multi-sourced posts by year

Closes #251.
main
welpo 1 year ago
parent c4e5a65908
commit 2c8a21d558
No known key found for this signature in database
GPG Key ID: A2F978CF4EC1F5A6

@ -25,24 +25,33 @@
{%- set_global all_posts = all_posts | concat(with=section_item.pages) -%} {%- set_global all_posts = all_posts | concat(with=section_item.pages) -%}
{%- endfor %} {%- endfor %}
{% for year, posts in all_posts | group_by(attribute="year") %} {# Group posts by year. #}
{% if posts | length > 0 %} {% set posts_by_year = all_posts | group_by(attribute="year") %}
<li> {% set years = [] %}
<h2 class="listing-title">{{ year }}</h2> {% for year, ignored in posts_by_year %}
<ul class="listing"> {% set_global years = years | concat(with=[year]) %}
{% for post in posts %} {% endfor %}
<li class="listing-item">
<div class="post-time"> {# Iterate over sorted & reversed years (newest to oldest). #}
<span class="date"> {% for year in years | sort | reverse %}
{{ post.date | date(format="%d %b", locale=date_locale) }} {% set posts = posts_by_year[year] %}
</span> {% if posts | length > 0 %}
</div> <li>
<a href="{{ post.permalink }}" title="{{ post.title }}">{{ post.title }}</a> <h2 class="listing-title">{{ year }}</h2>
</li> <ul class="listing">
{% endfor %} {% for post in posts %}
</ul> <li class="listing-item">
</li> <div class="post-time">
{% endif %} <span class="date">
{{ post.date | date(format="%d %b", locale=date_locale) }}
</span>
</div>
<a href="{{ post.permalink }}" title="{{ post.title }}">{{ post.title }}</a>
</li>
{% endfor %}
</ul>
</li>
{% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>

Loading…
Cancel
Save