add chapter sorting mechanism

This commit is contained in:
Yan Lin 2026-02-04 16:08:31 +01:00
parent a1a8d694e2
commit 592da6cad6
7 changed files with 34 additions and 4 deletions

View file

@ -17,21 +17,31 @@
{% else %}
{% set pages = section.pages %}
{% endif %}
{% if section.extra.use_chapter_sort %}
{% set pages = pages | sort(attribute="extra.chapter") %}
{% for page in pages %}
<li>
<span class="chapter">{{ page.extra.chapter }}</span>
<a href="{{ page.permalink }}">{{ page.title }}</a>
</li>
{% endfor %}
{% else %}
{% for page in pages %}
<li>
<time datetime="{{ page.date }}">{{ page.date | date(format="%Y-%m-%d") }}</time>
<a href="{{ page.permalink }}">{{ page.title }}</a>
</li>
{% endfor %}
{% endif %}
</ul>
{% if paginator %}
<nav class="pagination">
{% if paginator.previous %}
<a href="{{ paginator.previous }}">&larr; Newer</a>
<a href="{{ paginator.previous }}">&larr; {% if section.extra.use_chapter_sort %}Previous{% else %}Newer{% endif %}</a>
{% endif %}
{% if paginator.next %}
<a href="{{ paginator.next }}">Older &rarr;</a>
<a href="{{ paginator.next }}">{% if section.extra.use_chapter_sort %}Next{% else %}Older{% endif %} &rarr;</a>
{% endif %}
</nav>
{% endif %}