From 0cbd727f2521dda3f8980963adfcbada7fd00001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar?= Date: Thu, 2 May 2024 23:32:42 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20option=20to=20display?= =?UTF-8?q?/hide=20date=20in=20metadata=20(#306)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.toml | 4 ++++ content/blog/mastering-tabi-settings/index.ca.md | 10 +++++++++- content/blog/mastering-tabi-settings/index.es.md | 10 +++++++++- content/blog/mastering-tabi-settings/index.md | 10 +++++++++- templates/page.html | 15 ++++++++++----- theme.toml | 4 ++++ 6 files changed, 45 insertions(+), 8 deletions(-) diff --git a/config.toml b/config.toml index a5fe953..77d503e 100644 --- a/config.toml +++ b/config.toml @@ -132,6 +132,10 @@ copy_button = true # Can be set at page or section levels, following the hierarchy: page > section > config. See: https://welpo.github.io/tabi/blog/mastering-tabi-settings/#settings-hierarchy show_reading_time = true +# Show the date of a page below its title. +# Can be set at page or section levels, following the hierarchy: page > section > config. See: https://welpo.github.io/tabi/blog/mastering-tabi-settings/#settings-hierarchy +show_date = true + # Adds backlinks to footnotes (loads ~500 bytes of JavaScripts). # Can be set at page or section levels, following the hierarchy: page > section > config. See: https://welpo.github.io/tabi/blog/mastering-tabi-settings/#settings-hierarchy footnote_backlinks = false diff --git a/content/blog/mastering-tabi-settings/index.ca.md b/content/blog/mastering-tabi-settings/index.ca.md index 10efadd..c30e6b1 100644 --- a/content/blog/mastering-tabi-settings/index.ca.md +++ b/content/blog/mastering-tabi-settings/index.ca.md @@ -1,7 +1,7 @@ +++ title = "Domina la configuració de tabi: guia completa" date = 2023-09-18 -updated = 2024-04-23 +updated = 2024-05-02 description = "Descobreix les múltiples maneres en què pots personalitzar tabi." [taxonomies] @@ -698,6 +698,14 @@ Pots activar o desactivar el temps estimat de lectura d'un article amb `show_rea Com que segueix [la jerarquia](#jerarquia-de-configuracio), pots activar-lo o desactivar-lo per a pàgines o seccions específiques. Per exemple, aquesta demo desactiva `show_reading_time = false` a la secció [projectes](https://welpo.github.io/tabi/ca/projects/) a l'arxiu [`_index.md`](https://github.com/welpo/tabi/blob/main/content/projects/_index.es.md?plain=1), de manera que les seves publicacions individuals no mostren el temps de lectura. +### Mostrar la data + +| Pàgina | Secció | `config.toml` | Segueix la jerarquia | Requereix JavaScript | +|:------:|:------:|:-------------:|:--------------------:|:-------------------:| +| ✅ | ✅ | ✅ | ✅ | ❌ | + +Per defecte, la data es mostra sota el títol de la publicació. Pots amagar-la amb `show_date = false`. Aquest ajust segueix [la jerarquia](#jerarquia-de-configuracio). + ### Format de data | Pàgina | Secció | `config.toml` | Segueix la jerarquia | Requereix JavaScript | diff --git a/content/blog/mastering-tabi-settings/index.es.md b/content/blog/mastering-tabi-settings/index.es.md index 94715e4..8c5889c 100644 --- a/content/blog/mastering-tabi-settings/index.es.md +++ b/content/blog/mastering-tabi-settings/index.es.md @@ -1,7 +1,7 @@ +++ title = "Domina la configuración de tabi: guía completa" date = 2023-09-18 -updated = 2024-04-23 +updated = 2024-05-02 description = "Descubre las múltiples maneras en que puedes personalizar tabi." [taxonomies] @@ -700,6 +700,14 @@ Puedes activar o desactivar el tiempo estimado de lectura de un artículo con `s Dado que sigue [la jerarquía](#jerarquia-de-configuracion), puedes activarlo o desactivarlo para páginas o secciones específicas. Por ejemplo, esta demo desactiva `show_reading_time = false` en la sección [proyectos](https://welpo.github.io/tabi/es/projects/) en el archivo [`_index.md`](https://github.com/welpo/tabi/blob/main/content/projects/_index.es.md?plain=1), por lo que sus publicaciones individuales no muestran el tiempo de lectura. +### Mostrar la fecha + +| Página | Sección | `config.toml` | Sigue la jerarquía | Requiere JavaScript | +|:------:|:-------:|:-------------:|:------------------:|:-------------------:| +| ✅ | ✅ | ✅ | ✅ | ❌ | + +Por defecto, la fecha se muestra debajo del título de la publicación. Puedes ocultarla con `show_date = false`. Esta configuración sigue [la jerarquía](#jerarquia-de-configuracion). + ### Formato de fecha | Página | Sección | `config.toml` | Sigue la jerarquía | Requiere JavaScript | diff --git a/content/blog/mastering-tabi-settings/index.md b/content/blog/mastering-tabi-settings/index.md index ac1957e..65ffba7 100644 --- a/content/blog/mastering-tabi-settings/index.md +++ b/content/blog/mastering-tabi-settings/index.md @@ -1,7 +1,7 @@ +++ title = "Mastering tabi Settings: A Comprehensive Guide" date = 2023-09-18 -updated = 2024-04-23 +updated = 2024-05-02 description = "Discover the many ways you can customise your tabi site." [taxonomies] @@ -705,6 +705,14 @@ You can enable or hide the reading time of a post with `show_reading_time`. If y Since it follows [the hierarchy](#settings-hierarchy), you can enable it or hide it for specific pages or sections. For example, this demo sets `show_reading_time = false` in the [projects](https://welpo.github.io/tabi/projects/) section's [`_index.md`](https://github.com/welpo/tabi/blob/main/content/projects/_index.md?plain=1), so their individual posts don't show the reading time. +### Show Date + +| Page | Section | `config.toml` | Follows Hierarchy | Requires JavaScript | +|:----:|:-------:|:-------------:|:-----------------:|:-------------------:| +| ✅ | ✅ | ✅ | ✅ | ❌ | + +By default, the date is shown below the post title. You can hide it with `show_date = false`. This setting follows [the hierarchy](#settings-hierarchy). + ### Date Format | Page | Section | `config.toml` | Follows Hierarchy | Requires JavaScript | diff --git a/templates/page.html b/templates/page.html index c875bae..269e5fc 100644 --- a/templates/page.html +++ b/templates/page.html @@ -20,6 +20,7 @@ "katex", "quick_navigation_buttons", "show_reading_time", + "show_date", "show_remote_changes", "toc", "show_previous_next_article_links", @@ -64,17 +65,20 @@
  • {{ macros_translate::translate(key="draft", default="DRAFT", language_strings=language_strings) }}
  • {% endif %} - {% if page.date %} + {# page settings override config settings #} + {% if page.date and macros_settings::evaluate_setting_priority(setting="show_date", page=page, default_global_value=true) == "true" %}
  • {{ macros_format_date::format_date(date=page.date, short=true, language_strings=language_strings) }}
  • + {#- Variable to keep track of whether we've shown a section, to avoid separators as the first element -#} + {%- set previous_visible = true -%} {% endif %} - {# page settings override config settings #} {% if macros_settings::evaluate_setting_priority(setting="show_reading_time", page=page, default_global_value=true) == "true" %} - {{ separator }}
  • {{ macros_translate::translate(key="min_read", number=page.reading_time, default="$NUMBER min read", language_strings=language_strings) }}
  • + {%- if previous_visible -%}{{ separator }} {%- endif -%}
  • {{ macros_translate::translate(key="min_read", number=page.reading_time, default="$NUMBER min read", language_strings=language_strings) }}
  • + {%- set previous_visible = true -%} {% endif %} {%- if page.taxonomies and page.taxonomies.tags -%} - {{ separator }} 
  • {{- macros_translate::translate(key="tags", default="tags", language_strings=language_strings) | capitalize -}}: 
  • + {%- if previous_visible -%} {{ separator }} {%- endif -%}
  • {{- macros_translate::translate(key="tags", default="tags", language_strings=language_strings) | capitalize -}}: 
  • {%- for tag in page.taxonomies.tags -%}
  • {{ tag }} {%- if not loop.last -%} @@ -82,13 +86,14 @@ {%- endif -%}
  • {%- endfor -%} + {%- set previous_visible = true -%} {%- endif -%} {% if page.updated %}