From 9d49a6535478557b2cb2c25a2b794c8c2a6e260e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar?= Date: Mon, 27 May 2024 02:16:03 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20option=20to=20show=20?= =?UTF-8?q?author=20in=20post=20metadata=20(#322)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.toml | 4 ++ .../blog/mastering-tabi-settings/index.ca.md | 12 +++- .../blog/mastering-tabi-settings/index.es.md | 12 +++- content/blog/mastering-tabi-settings/index.md | 12 +++- i18n/ar.toml | 3 + i18n/ca.toml | 3 + i18n/de.toml | 3 + i18n/en.toml | 3 + i18n/es.toml | 3 + i18n/fa.toml | 3 + i18n/fr.toml | 3 + i18n/hi.toml | 3 + i18n/it.toml | 3 + i18n/ja.toml | 3 + i18n/ko.toml | 3 + i18n/nl.toml | 3 + i18n/pt-PT.toml | 3 + i18n/ru.toml | 3 + i18n/uk.toml | 3 + i18n/zh-Hans.toml | 3 + i18n/zh-Hant.toml | 3 + templates/macros/format_date.html | 66 +++++++++---------- templates/page.html | 35 +++++++++- theme.toml | 4 ++ 24 files changed, 157 insertions(+), 39 deletions(-) diff --git a/config.toml b/config.toml index d8aa34782..62f4bcff6 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 add_src_to_code_block = false +# Show the author(s) of a page. +# 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_author = false + # Show the reading time of a page. # 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 diff --git a/content/blog/mastering-tabi-settings/index.ca.md b/content/blog/mastering-tabi-settings/index.ca.md index 431b74030..0f2322b8b 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-05-03 +updated = 2024-05-25 description = "Descobreix les múltiples maneres en què pots personalitzar tabi." [taxonomies] @@ -694,6 +694,16 @@ copyright_translations.es = "© $CURRENT_YEAR $AUTHOR $SEPARATOR A menos que se ## Metadades +### Mostrar autoria + +| Pàgina | Secció | `config.toml` | Segueix la jerarquia | Requereix JavaScript | +|:------:|:-------:|:-------------:|:---------------------:|:-------------------:| +| ✅ | ✅ | ✅ | ✅ | ❌ | + +Per mostrar l'autoria d'un article, estableix `show_author = true`. + +Això mostrarà els autors establerts a la variable `authors = []` al front matter del post. Si aquest camp no està configurat, mostrarà l'autor de `config.toml` (`author = ""`). + ### Temps de lectura | 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 ae8958511..2b780bd8a 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-05-03 +updated = 2024-05-25 description = "Descubre las múltiples maneras en que puedes personalizar tabi." [taxonomies] @@ -696,6 +696,16 @@ copyright_translations.es = "© $CURRENT_YEAR $AUTHOR $SEPARATOR A menos que se ## Metadatos +### Mostrar autoría + +| Página | Sección | `config.toml` | Respeta jerarquía | Requiere JavaScript | +|:------:|:-------:|:-------------:|:-----------------:|:-------------------:| +| ✅ | ✅ | ✅ | ✅ | ❌ | + +Para mostrar la autoría de un artículo, usa `show_author = true`. + +Esto mostrará lxs autorxs establecidxs en la variable `authors = []` en el front matter del artículo. Si esto no está disponible, se usará `author = ""` en `config.toml`. + ### Tiempo de lectura | Página | Sección | `config.toml` | Respeta jerarquía | Requiere JavaScript | diff --git a/content/blog/mastering-tabi-settings/index.md b/content/blog/mastering-tabi-settings/index.md index 1bdee31c2..3c83e58e7 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-05-19 +updated = 2024-05-27 description = "Discover the many ways you can customise your tabi site." [taxonomies] @@ -701,6 +701,16 @@ copyright_translations.es = "© $CURRENT_YEAR $AUTHOR $SEPARATOR A menos que se ## Metadata +### Show author + +| Page | Section | `config.toml` | Follows Hierarchy | Requires JavaScript | +|:----:|:-------:|:-------------:|:-----------------:|:-------------------:| +| ✅ | ✅ | ✅ | ✅ | ❌ | + +To show the author(s) below the post title, set `show_author = true`. + +This will display the authors set on `authors = []` in the front matter of the post. If this is not available, it will fall back to `author = ""`in `config.toml`. + ### Reading Time | Page | Section | `config.toml` | Follows Hierarchy | Requires JavaScript | diff --git a/i18n/ar.toml b/i18n/ar.toml index 30c7aead0..250526e1d 100644 --- a/i18n/ar.toml +++ b/i18n/ar.toml @@ -54,6 +54,9 @@ go_to_top = "انتقل إلى أعلى الصفحة" go_to_comments = "انتقل إلى التعليقات" # Post metadata. +by_author = "بقلم $AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = "، " # For multiple authors. Ensure spacing where necessary. +author_conjunction = " و " # For multiple authors. Ensure spacing where necessary. draft = "مسودة" zero_min_read = "الوقت المتوقع للقراءة: أقل من دقيقة" #Less than one minute read. one_min_read = "الوقت المتوقع للقراءة: دقيقة واحدة" #One minute read. diff --git a/i18n/ca.toml b/i18n/ca.toml index 5d8dfd7c3..15325740c 100644 --- a/i18n/ca.toml +++ b/i18n/ca.toml @@ -45,6 +45,9 @@ go_to_top = "Vés a l'inici de la pàgina" go_to_comments = "Vés a la secció de comentaris" # Post metadata. +by_author = "Per $AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = ", " # For multiple authors. Ensure spacing where necessary. +author_conjunction = " i " # For multiple authors. Ensure spacing where necessary. draft = "ESBORRANY" zero_min_read = "<1 min de lectura" one_min_read = "$NUMBER min de lectura" diff --git a/i18n/de.toml b/i18n/de.toml index 843356392..a633b68d0 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -49,6 +49,9 @@ go_to_top = "Zum Seitenanfang" go_to_comments = "Zum Kommentarbereich" # Post metadata. +by_author = "Von $AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = ", " # For multiple authors. Ensure spacing where necessary. +author_conjunction = " und " # For multiple authors. Ensure spacing where necessary. draft = "ENTWURF" zero_min_read = "weniger als 1 Min. Lesezeit" one_min_read = "$NUMBER Min. Lesezeit" diff --git a/i18n/en.toml b/i18n/en.toml index 5fd90a9f6..ae5f02e77 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -45,6 +45,9 @@ go_to_top = "Go to the top of the page" go_to_comments = "Go to the comments section" # Post metadata. +by_author = "By $AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = ", " # For multiple authors. Ensure spacing where necessary. +author_conjunction = " and " # For multiple authors. Ensure spacing where necessary. draft = "DRAFT" zero_min_read = "<1 min read" one_min_read = "$NUMBER min read" diff --git a/i18n/es.toml b/i18n/es.toml index 431a1a9c3..7e0fe0ce2 100644 --- a/i18n/es.toml +++ b/i18n/es.toml @@ -45,6 +45,9 @@ go_to_top = "Ir al inicio de la página" go_to_comments = "Ir a la sección de comentarios" # Post metadata. +by_author = "Por $AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = ", " # For multiple authors. Ensure spacing where necessary. +author_conjunction = " y " # For multiple authors. Ensure spacing where necessary. draft = "BORRADOR" zero_min_read = "<1 min de lectura" one_min_read = "$NUMBER min de lectura" diff --git a/i18n/fa.toml b/i18n/fa.toml index c96e337e1..9f1a55311 100644 --- a/i18n/fa.toml +++ b/i18n/fa.toml @@ -46,6 +46,9 @@ go_to_top = "رفتن به بالای صفحه" go_to_comments = "رفتن به بخش نظرات" # Post metadata. +by_author = "توسط $AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = "، " # For multiple authors. Ensure spacing where necessary. +author_conjunction = " و " # For multiple authors. Ensure spacing where necessary. draft = "پیش‌نویس" zero_min_read = "خواندن کمتر از ۱ دقیقه" one_min_read = "خواندن $NUMBER دقیقه" diff --git a/i18n/fr.toml b/i18n/fr.toml index c65c0e470..f5b7963e5 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -45,6 +45,9 @@ go_to_top = "Aller en haut de la page" go_to_comments = "Aller à la section des commentaires" # Post metadata. +by_author = "Par $AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = ", " # For multiple authors. Ensure spacing where necessary. +author_conjunction = " et " # For multiple authors. Ensure spacing where necessary. draft = "BROUILLON" zero_min_read = "<1 min de lecture" one_min_read = "$NUMBER min de lecture" diff --git a/i18n/hi.toml b/i18n/hi.toml index b28c406f2..ab00aa77e 100644 --- a/i18n/hi.toml +++ b/i18n/hi.toml @@ -47,6 +47,9 @@ go_to_top = "पृष्ठ के शीर्ष पर जाएं" go_to_comments = "टिप्पणी अनुभाग में जाएं" # Post metadata. +by_author = "$AUTHOR द्वारा" # $AUTHOR will be replaced by the author(s). +author_separator = ", " # For multiple authors. Ensure spacing where necessary. +author_conjunction = " और " # For multiple authors. Ensure spacing where necessary. draft = "मसौदा" zero_min_read = "कम से कम 1 मिनट पठन समय" one_min_read = "$NUMBER मिनट पठन समय" diff --git a/i18n/it.toml b/i18n/it.toml index 9db67e92c..54b55d254 100644 --- a/i18n/it.toml +++ b/i18n/it.toml @@ -45,6 +45,9 @@ go_to_top = "Vai in cima alla pagina" go_to_comments = "Vai alla sezione commenti" # Post metadata. +by_author = "Di $AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = ", " # For multiple authors. Ensure spacing where necessary. +author_conjunction = " e " # For multiple authors. Ensure spacing where necessary. draft = "BOZZA" zero_min_read = "<1 min di lettura" one_min_read = "$NUMBER min di lettura" diff --git a/i18n/ja.toml b/i18n/ja.toml index f6372af64..424191416 100644 --- a/i18n/ja.toml +++ b/i18n/ja.toml @@ -49,6 +49,9 @@ go_to_top = "ページの先頭へ" go_to_comments = "コメントセクションへ" # Post metadata. +by_author = "$AUTHOR によって" # $AUTHOR will be replaced by the author(s). +author_separator = "、" # For multiple authors. Ensure spacing where necessary. +author_conjunction = "と" # For multiple authors. Ensure spacing where necessary. draft = "ドラフト" zero_min_read = "1分未満の読了時間" one_min_read = "$NUMBER 分の読了時間" diff --git a/i18n/ko.toml b/i18n/ko.toml index 6d00cb98a..1e3097dc6 100644 --- a/i18n/ko.toml +++ b/i18n/ko.toml @@ -49,6 +49,9 @@ go_to_top = "페이지 상단으로" go_to_comments = "댓글 섹션으로" # Post metadata. +by_author = "$AUTHOR 작성" # $AUTHOR will be replaced by the author(s). +author_separator = "、" # For multiple authors. Ensure spacing where necessary. +author_conjunction = "와" # For multiple authors. Ensure spacing where necessary. draft = "임시 저장" zero_min_read = "1분 미만 읽기" one_min_read = "$NUMBER 분 읽기" diff --git a/i18n/nl.toml b/i18n/nl.toml index 827b7fe28..5446b6c71 100644 --- a/i18n/nl.toml +++ b/i18n/nl.toml @@ -45,6 +45,9 @@ go_to_top = "Ga naar de bovenkant van de pagina" go_to_comments = "Ga naar opmerkingen" # Post metadata. +by_author = "Door $AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = ", " # For multiple authors. Ensure spacing where necessary. +author_conjunction = " en " # For multiple authors. Ensure spacing where necessary. draft = "VOORLOPIGE VERSIE" zero_min_read = "<1 minuut lezen" one_min_read = "$NUMBER minuut lezen" diff --git a/i18n/pt-PT.toml b/i18n/pt-PT.toml index 0c216455a..d1044270a 100644 --- a/i18n/pt-PT.toml +++ b/i18n/pt-PT.toml @@ -45,6 +45,9 @@ go_to_top = "Ir para o topo da página" go_to_comments = "Ir para a seção de comentários" # Post metadata. +by_author = "Por $AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = ", " # For multiple authors. Ensure spacing where necessary. +author_conjunction = " e " # For multiple authors. Ensure spacing where necessary. draft = "RASCUNHO" zero_min_read = "<1 min de leitura" one_min_read = "$NUMBER min de leitura" diff --git a/i18n/ru.toml b/i18n/ru.toml index f58e110a2..12c94dbc1 100644 --- a/i18n/ru.toml +++ b/i18n/ru.toml @@ -52,6 +52,9 @@ go_to_top = "Перейти в начало страницы" go_to_comments = "Перейти к комментариям" # Post metadata. +by_author = "От $AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = ", " # For multiple authors. Ensure spacing where necessary. +author_conjunction = " и " # For multiple authors. Ensure spacing where necessary. draft = "ЧЕРНОВИК" zero_min_read = "<1 мин чтения" one_min_read = "$NUMBER мин чтения" diff --git a/i18n/uk.toml b/i18n/uk.toml index 35337655c..7b1519d57 100644 --- a/i18n/uk.toml +++ b/i18n/uk.toml @@ -56,6 +56,9 @@ go_to_top = "Перейти на початок сторінки" go_to_comments = "Перейти до коментарів" # Post metadata. +by_author = "Від $AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = ", " # For multiple authors. Ensure spacing where necessary. +author_conjunction = " і " # For multiple authors. Ensure spacing where necessary. draft = "ЧЕРНЕТКА" zero_min_read = "<1 хв. читання" one_min_read = "$NUMBER хв. читання" diff --git a/i18n/zh-Hans.toml b/i18n/zh-Hans.toml index ff5c54260..96f8b080c 100644 --- a/i18n/zh-Hans.toml +++ b/i18n/zh-Hans.toml @@ -45,6 +45,9 @@ go_to_top = "返回页面顶部" # Machine translated. go_to_comments = "转到评论区" # Machine translated. # Post metadata. +by_author = "由$AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = "、" # For multiple authors. Ensure spacing where necessary. +author_conjunction = "和" # For multiple authors. Ensure spacing where necessary. draft = "草稿" zero_min_read = "少于1分钟阅读" one_min_read = "$NUMBER 分钟阅读" diff --git a/i18n/zh-Hant.toml b/i18n/zh-Hant.toml index 34b1864e5..36769bcbe 100644 --- a/i18n/zh-Hant.toml +++ b/i18n/zh-Hant.toml @@ -45,6 +45,9 @@ go_to_top = "返回頁面頂部" # Machine translated. go_to_comments = "轉到評論區" # Machine translated. # Post metadata. +by_author = "由$AUTHOR" # $AUTHOR will be replaced by the author(s). +author_separator = "、" # For multiple authors. Ensure spacing where necessary. +author_conjunction = "和" # For multiple authors. Ensure spacing where necessary. draft = "草稿" zero_min_read = "少於1分鐘閱讀" one_min_read = "$NUMBER 分鐘閱讀" diff --git a/templates/macros/format_date.html b/templates/macros/format_date.html index 4ee9f6e51..3d22eba34 100644 --- a/templates/macros/format_date.html +++ b/templates/macros/format_date.html @@ -1,43 +1,43 @@ -{% macro format_date(date, short, language_strings="") %} +{%- macro format_date(date, short, language_strings="") -%} -{# Set locale #} -{% set date_locale = macros_translate::translate(key="date_locale", default="en_GB", language_strings=language_strings) %} +{#- Set locale -#} +{%- set date_locale = macros_translate::translate(key="date_locale", default="en_GB", language_strings=language_strings) -%} -{% if config.extra.short_date_format and short %} +{%- if config.extra.short_date_format and short -%} {{ date | date(format=config.extra.short_date_format, locale=date_locale) }} -{% elif config.extra.long_date_format and not short %} +{%- elif config.extra.long_date_format and not short -%} {{ date | date(format=config.extra.long_date_format, locale=date_locale) }} -{% elif not config.extra.short_date_format and date_locale == "en_GB" %} - {% set day = date | date(format='%-d') | int %} +{%- elif not config.extra.short_date_format and date_locale == "en_GB" -%} + {%- set day = date | date(format='%-d') | int -%} - {% if day in [11, 12, 13] %} - {% set suffix = "th" %} - {% else %} - {% set last_digit = day % 10 %} - {% if last_digit == 1 %} - {% set suffix = "st" %} - {% elif last_digit == 2 %} - {% set suffix = "nd" %} - {% elif last_digit == 3 %} - {% set suffix = "rd" %} - {% else %} - {% set suffix = "th" %} - {% endif %} - {% endif %} + {%- if day in [11, 12, 13] -%} + {%- set suffix = "th" -%} + {%- else -%} + {%- set last_digit = day % 10 -%} + {%- if last_digit == 1 -%} + {%- set suffix = "st" -%} + {%- elif last_digit == 2 -%} + {%- set suffix = "nd" -%} + {%- elif last_digit == 3 -%} + {%- set suffix = "rd" -%} + {%- else -%} + {%- set suffix = "th" -%} + {%- endif -%} + {%- endif -%} - {# Return the date. #} + {#- Return the date. -#} {{ date | date(format="%-d") }}{{ suffix }} - {% if short == true %} - {{ date | date(format="%b %Y") }} - {% else %} - {{ date | date(format="%B %Y") }} - {% endif %} -{% else %} - {% if short %} + {%- if short == true -%} + {{ date | date(format=" %b %Y") }} + {%- else -%} + {{ date | date(format=" %B %Y") }} + {%- endif -%} +{%- else -%} + {%- if short -%} {{ date | date(format="%-d %b %Y", locale=date_locale) }} - {% else %} + {%- else -%} {{ date | date(format="%d %b %Y", locale=date_locale) }} - {% endif %} -{% endif %} + {%- endif -%} +{%- endif -%} -{% endmacro %} +{%- endmacro -%} diff --git a/templates/page.html b/templates/page.html index 762064049..eed6f52bc 100644 --- a/templates/page.html +++ b/templates/page.html @@ -23,6 +23,7 @@ "quick_navigation_buttons", "show_reading_time", "show_date", + "show_author", "show_remote_changes", "toc", "show_previous_next_article_links", @@ -63,22 +64,49 @@