diff --git a/config.toml b/config.toml index 354908e01..d77c9acd3 100644 --- a/config.toml +++ b/config.toml @@ -192,6 +192,11 @@ separator = "•" # Compact: tag_name^n (superscript number) compact_tags = false +# How tags are sorted in a Tags listing based on templates/tags/list.html. +# "name" for alphabetical, "frequency" for descending count of posts. +# Default: "name". +tag_sorting = "name" + # Invert the order of the site title and page title in the browser tab. # Example: true => "Blog • ~/tabi", false => "~/tabi • Blog" invert_title_order = false diff --git a/content/blog/mastering-tabi-settings/index.ca.md b/content/blog/mastering-tabi-settings/index.ca.md index 2641631bb..70fd7c656 100644 --- a/content/blog/mastering-tabi-settings/index.ca.md +++ b/content/blog/mastering-tabi-settings/index.ca.md @@ -229,7 +229,7 @@ Aquesta variable accepta qualsevol color CSS vàlid, així que pots utilitzar pa |:------:|:------:|:-------------:|:-----------------:|:--------------------:| | ❌ | ❌ | ✅ | ❌ | ❌ | -Per defecte, la [pàgina d'etiquetes](/tags) mostra les etiquetes com: +Per defecte, la [pàgina d'etiquetes](/ca/tags) mostra les etiquetes com: [NomEtiqueta](#) — n entrada[es] @@ -237,6 +237,15 @@ Establir `compact_tags = true` les mostrarà com: [NomEtiqueta](#) n +### Ordre de les etiquetes + +| Pàgina | Secció | `config.toml` | Segueix la jerarquia | Requereix JavaScript | +|:------:|:------:|:-------------:|:-----------------:|:--------------------:| +| ❌ | ❌ | ✅ | ❌ | ❌ | + +Per defecte, la [pàgina d'etiquetes](/ca/tags) ordena les etiquetes alfabèticament, donada la configuració predeterminada de `tag_sorting = "name"`. +Si configures `tag_sorting = "frequency"`, s'ordenaran segons el nombre de publicacions (de més a menys). + --- ## Integració amb repositoris Git diff --git a/content/blog/mastering-tabi-settings/index.es.md b/content/blog/mastering-tabi-settings/index.es.md index 451c7a39c..2695d7f7b 100644 --- a/content/blog/mastering-tabi-settings/index.es.md +++ b/content/blog/mastering-tabi-settings/index.es.md @@ -237,6 +237,15 @@ Establecer `compact_tags = true` mostrará las mismas de este modo: [NombreEtiqueta](#) n +### Orden de las etiquetas + +| Página | Sección | `config.toml` | Sigue la jerarquía | Requiere JavaScript | +|:------:|:-------:|:-------------:|:---------------:|:-------------------:| +| ❌ | ❌ | ✅ | ❌ | ❌ | + +Por defecto, la [página de etiquetas](/es/tags) ordena las etiquetas alfabéticamente, dada la configuración predeterminada de `tag_sorting = "name"`. +Si configuras `tag_sorting = "frequency"`, se ordenarán según el número de publicaciones (de mayor a menor). + --- ## Integración con repositorios Git diff --git a/content/blog/mastering-tabi-settings/index.md b/content/blog/mastering-tabi-settings/index.md index c46f5a1a2..319a8b1bc 100644 --- a/content/blog/mastering-tabi-settings/index.md +++ b/content/blog/mastering-tabi-settings/index.md @@ -237,6 +237,16 @@ Setting `compact_tags = true` will display them as: [TagName](#) n +### Tags Sorting + +| Page | Section | `config.toml` | Follows Hierarchy | Requires JavaScript | +|:----:|:-------:|:-------------:|:-----------------:|:-------------------:| +| ❌ | ❌ | ✅ | ❌ | ❌ | + +By default, the [tags page](/tags) sorts tags alphabetically, given the default setting of `tag_sorting = "name"`. + +Setting `tag_sorting = "frequency"` will sort them by number-of-posts (descending). + --- ## Git Repository Integration diff --git a/templates/tags/list.html b/templates/tags/list.html index 4aaaeba11..7b5e46828 100644 --- a/templates/tags/list.html +++ b/templates/tags/list.html @@ -7,6 +7,11 @@ {{ macros_page_header::page_header(title=title)}} {% set tag_count = terms | length %} +{% if config.extra.tag_sorting == "frequency" %} + {% set terms = terms | sort(attribute="pages") | reverse %} +{% elif config.extra.tag_sorting != "name" %} + {{ throw (message="Invalid tag_sorting option: " ~ config.extra.tag_sorting ~ ". Valid options are 'name' and 'frequency'.") }} +{% endif %}