-
Checklist
How did you create the site?Generated from DescriptionI want the archive page to show older ones from top. Operations you have already triedI tried to look through the archive template file in the original chirpy repo, I couldn't figure out anything. Anything else?Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You did it right. You need to copy I can propose to sort posts by date before iterating over them: {% assign posts = site.posts | sort: 'date' %}
{% for post in posts %} Here is the full layout definition: ---
layout: page
# The Archives of posts.
---
{% include lang.html %}
{% assign df_strftime_m = site.data.locales[lang].df.archives.strftime | default: '/ %m' %}
{% assign df_dayjs_m = site.data.locales[lang].df.archives.dayjs | default: '/ MM' %}
<div id="archives" class="pl-xl-3">
{% assign posts = site.posts | sort: 'date' %}
{% for post in posts %}
{% assign cur_year = post.date | date: '%Y' %}
{% if cur_year != last_year %}
{% unless forloop.first %}</ul>{% endunless %}
<time class="year lead d-block">{{ cur_year }}</time>
{{ '<ul class="list-unstyled">' }}
{% assign last_year = cur_year %}
{% endif %}
<li>
{% assign ts = post.date | date: '%s' %}
<span class="date day" data-ts="{{ ts }}" data-df="DD">{{ post.date | date: '%d' }}</span>
<span class="date month small text-muted ms-1" data-ts="{{ ts }}" data-df="{{ df_dayjs_m }}">
{{ post.date | date: df_strftime_m }}
</span>
<a href="{{ post.url | relative_url }}">{{ post.title }}</a>
</li>
{% if forloop.last %}</ul>{% endif %}
{% endfor %}
</div> |
Beta Was this translation helpful? Give feedback.
-
It worked 😁 |
Beta Was this translation helpful? Give feedback.
You did it right. You need to copy
_layouts/archives.html
to your repo and adjust the layout to serve your needs.I can propose to sort posts by date before iterating over them:
Here is the full layout definition: