feat: add archive view of posts

This commit is contained in:
Devin Haska 2024-02-07 20:02:59 -08:00
parent 5e72b839fe
commit 6265474981
8 changed files with 78 additions and 10 deletions

View file

@ -0,0 +1,23 @@
{% set postsByDate = posts | entries %}
<section>
{% for postsGroupedByYear in postsByDate %}
{% set year = postsGroupedByYear | first %}
{% set postsGroupedByMonth = postsGroupedByYear | last | entries %}
{% for postsInMonth in postsGroupedByMonth %}
{% set isFirstMonthOfList = loop.index0 === 0 %}
{% set month = postsInMonth | first %}
<div class="[ flex ]">
{% if isFirstMonthOfList %}<h2>{{ year }}</h2>{% endif %}
<h2 class="[ archive-month ]">{{ month }}</h2>
</div>
{% set allPosts = postsInMonth | last %}
{% for post in allPosts %}
<div class="[ flex items-center justify-between ]">
<a href="{{ post.url }}">{{ post.data.title }}</a>
<div class="[ archive-divider ] [ mx-0.5 ]"></div>
<div>{{ post.date | formatDate("Do") }}</div>
</div>
{% endfor %}
{% endfor %}
{% endfor %}
</section>