feat: add archive view of posts
This commit is contained in:
parent
5e72b839fe
commit
6265474981
8 changed files with 78 additions and 10 deletions
23
src/_includes/partials/posts.html
Normal file
23
src/_includes/partials/posts.html
Normal 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>
|
Loading…
Add table
Add a link
Reference in a new issue