forked from deepStateMirrors/tabi
💥 feat(archive)!: enforce chronological sorting (#483)
This commit is contained in:
parent
d777d5d996
commit
6ff0604beb
4 changed files with 38 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
||||||
+++
|
+++
|
||||||
title = "Domina la configuració de tabi: guia completa"
|
title = "Domina la configuració de tabi: guia completa"
|
||||||
date = 2023-09-18
|
date = 2023-09-18
|
||||||
updated = 2025-02-02
|
updated = 2025-02-09
|
||||||
description = "Descobreix les múltiples maneres en què pots personalitzar tabi."
|
description = "Descobreix les múltiples maneres en què pots personalitzar tabi."
|
||||||
|
|
||||||
[taxonomies]
|
[taxonomies]
|
||||||
|
@ -438,10 +438,14 @@ Per defecte, l'arxiu llistarà les publicacions situades a `blog/`. Per personal
|
||||||
section_path = ["blog/", "notes/", "camí-tres/"]
|
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.
|
```toml
|
||||||
- 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`.
|
[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
|
### Etiquetes
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
+++
|
+++
|
||||||
title = "Domina la configuración de tabi: guía completa"
|
title = "Domina la configuración de tabi: guía completa"
|
||||||
date = 2023-09-18
|
date = 2023-09-18
|
||||||
updated = 2025-02-02
|
updated = 2025-02-09
|
||||||
description = "Descubre las múltiples maneras en que puedes personalizar tabi."
|
description = "Descubre las múltiples maneras en que puedes personalizar tabi."
|
||||||
|
|
||||||
[taxonomies]
|
[taxonomies]
|
||||||
|
@ -438,10 +438,14 @@ Por defecto, el archivo mostrará las publicaciones ubicadas en `blog/`. Para pe
|
||||||
section_path = ["blog/", "notas/", "ruta-tres/"]
|
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.
|
```toml
|
||||||
- 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`.
|
[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
|
### Etiquetas
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
+++
|
+++
|
||||||
title = "Mastering tabi Settings: A Comprehensive Guide"
|
title = "Mastering tabi Settings: A Comprehensive Guide"
|
||||||
date = 2023-09-18
|
date = 2023-09-18
|
||||||
updated = 2025-02-02
|
updated = 2025-02-09
|
||||||
description = "Discover the many ways you can customise your tabi site."
|
description = "Discover the many ways you can customise your tabi site."
|
||||||
|
|
||||||
[taxonomies]
|
[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/"]
|
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.
|
```toml
|
||||||
- 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`.
|
[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
|
### Tags
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,13 @@
|
||||||
{%- set_global all_posts = all_posts | concat(with=section_item.pages) -%}
|
{%- set_global all_posts = all_posts | concat(with=section_item.pages) -%}
|
||||||
{%- endfor %}
|
{%- 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. #}
|
{# Group posts by year. #}
|
||||||
{% set posts_by_year = all_posts | group_by(attribute="year") %}
|
{% set posts_by_year = all_posts | group_by(attribute="year") %}
|
||||||
{% set years = [] %}
|
{% set years = [] %}
|
||||||
|
@ -32,8 +39,13 @@
|
||||||
{% set_global years = years | concat(with=[year]) %}
|
{% set_global years = years | concat(with=[year]) %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{# Iterate over sorted & reversed years (newest to oldest). #}
|
{# Iterate over years #}
|
||||||
{% for year in years | sort | reverse %}
|
{% set years = years | sort %}
|
||||||
|
{%- if not archive_reverse -%}
|
||||||
|
{%- set years = years | reverse -%}
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
|
{% for year in years %}
|
||||||
{% set posts = posts_by_year[year] %}
|
{% set posts = posts_by_year[year] %}
|
||||||
{% if posts | length > 0 %}
|
{% if posts | length > 0 %}
|
||||||
<li>
|
<li>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue