mirror of
https://github.com/welpo/tabi.git
synced 2025-10-11 07:46:15 +02:00
💥 feat(archive)!: enforce chronological sorting
Previously, the archive template respected individual section sorting configurations, leading to potentially inconsistent timeline display. This change enforces strict chronological sorting (by publication date) across all archive posts and adds an `archive_reverse` option in section.extra to control sort direction. BREAKING CHANGE: Archive now ignores section-specific sort_by settings in favour of publication date ordering.
This commit is contained in:
parent
d777d5d996
commit
13a65ac741
4 changed files with 38 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
|||
+++
|
||||
title = "Domina la configuració de tabi: guia completa"
|
||||
date = 2023-09-18
|
||||
updated = 2025-02-02
|
||||
updated = 2025-02-09
|
||||
description = "Descobreix les múltiples maneres en què pots personalitzar tabi."
|
||||
|
||||
[taxonomies]
|
||||
|
@ -438,10 +438,14 @@ Per defecte, l'arxiu llistarà les publicacions situades a `blog/`. Per personal
|
|||
section_path = ["blog/", "notes/", "camí-tres/"]
|
||||
```
|
||||
|
||||
**Nota**:
|
||||
L'arxiu mostra les publicacions en ordre cronològic invers (les més recents primer). Pots invertir aquest ordre establint `archive_reverse = true` a la secció `[extra]`:
|
||||
|
||||
- La pàgina d'arxiu només llistarà publicacions amb data.
|
||||
- L'ordre de les publicacions ve determinada per la variable `sort_by` de les seccions arxivades. Aquesta demo utilitza `sort_by = "date"` en `blog/_index.md`.
|
||||
```toml
|
||||
[extra]
|
||||
archive_reverse = true # mostra les publicacions més antigues primer
|
||||
```
|
||||
|
||||
{{ admonition(type="note", title="nota" text="La pàgina d'arxiu només llistarà publicacions que tinguin data al seu encapçalament.") }}
|
||||
|
||||
### Etiquetes
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
+++
|
||||
title = "Domina la configuración de tabi: guía completa"
|
||||
date = 2023-09-18
|
||||
updated = 2025-02-02
|
||||
updated = 2025-02-09
|
||||
description = "Descubre las múltiples maneras en que puedes personalizar tabi."
|
||||
|
||||
[taxonomies]
|
||||
|
@ -438,10 +438,14 @@ Por defecto, el archivo mostrará las publicaciones ubicadas en `blog/`. Para pe
|
|||
section_path = ["blog/", "notas/", "ruta-tres/"]
|
||||
```
|
||||
|
||||
**Nota**:
|
||||
El archivo muestra las publicaciones en orden cronológico inverso (las más recientes primero). Puedes invertir este orden estableciendo `archive_reverse = true` en la sección `[extra]`:
|
||||
|
||||
- La página de Archivo sólo listará publicaciones con fecha.
|
||||
- El orden las publicaciones viene determinada por la variable `sort_by` de las secciones archivadas. Esta demo utiliza `sort_by = "date"` en `blog/_index.md`.
|
||||
```toml
|
||||
[extra]
|
||||
archive_reverse = true # muestra las publicaciones más antiguas primero
|
||||
```
|
||||
|
||||
{{ admonition(type="note", title="nota" text="La página de Archivo sólo listará publicaciones que tengan fecha en su encabezado.") }}
|
||||
|
||||
### Etiquetas
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
+++
|
||||
title = "Mastering tabi Settings: A Comprehensive Guide"
|
||||
date = 2023-09-18
|
||||
updated = 2025-02-02
|
||||
updated = 2025-02-09
|
||||
description = "Discover the many ways you can customise your tabi site."
|
||||
|
||||
[taxonomies]
|
||||
|
@ -443,10 +443,14 @@ By default, the archive will list posts located in `blog/`. To customise this, y
|
|||
section_path = ["blog/", "notes/", "path-three/"]
|
||||
```
|
||||
|
||||
**Notes**:
|
||||
The archive displays posts in reverse chronological order (newest first). You can reverse this order by setting `archive_reverse = true` in the `[extra]` section:
|
||||
|
||||
- the Archive page will only list posts that have a date in their front matter.
|
||||
- Post sorting is determined by the `sort_by` variable of the sections you are archiving. This demo uses `sort_by = "date"` set in the `blog/_index.md`.
|
||||
```toml
|
||||
[extra]
|
||||
archive_reverse = true # displays oldest posts first.
|
||||
```
|
||||
|
||||
{{ admonition(type="note", text="The Archive page will only list posts that have a date in their front matter.") }}
|
||||
|
||||
### Tags
|
||||
|
||||
|
|
|
@ -25,6 +25,13 @@
|
|||
{%- set_global all_posts = all_posts | concat(with=section_item.pages) -%}
|
||||
{%- endfor %}
|
||||
|
||||
{# Sort all posts by date #}
|
||||
{%- set archive_reverse = section.extra.archive_reverse | default(value=false) -%}
|
||||
{%- set all_posts = all_posts | sort(attribute="date") -%}
|
||||
{%- if not archive_reverse -%}
|
||||
{%- set all_posts = all_posts | reverse -%}
|
||||
{%- endif -%}
|
||||
|
||||
{# Group posts by year. #}
|
||||
{% set posts_by_year = all_posts | group_by(attribute="year") %}
|
||||
{% set years = [] %}
|
||||
|
@ -32,8 +39,13 @@
|
|||
{% set_global years = years | concat(with=[year]) %}
|
||||
{% endfor %}
|
||||
|
||||
{# Iterate over sorted & reversed years (newest to oldest). #}
|
||||
{% for year in years | sort | reverse %}
|
||||
{# Iterate over years #}
|
||||
{% set years = years | sort %}
|
||||
{%- if not archive_reverse -%}
|
||||
{%- set years = years | reverse -%}
|
||||
{%- endif -%}
|
||||
|
||||
{% for year in years %}
|
||||
{% set posts = posts_by_year[year] %}
|
||||
{% if posts | length > 0 %}
|
||||
<li>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue