feat: add option to show author in post metadata (#322)

main
Óscar 11 months ago committed by GitHub
parent 86a4e5f5f4
commit 9d49a65354
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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

@ -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 |

@ -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 |

@ -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 |

@ -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.

@ -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"

@ -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"

@ -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"

@ -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"

@ -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 دقیقه"

@ -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"

@ -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 मिनट पठन समय"

@ -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"

@ -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 分の読了時間"

@ -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 분 읽기"

@ -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"

@ -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"

@ -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 мин чтения"

@ -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 хв. читання"

@ -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 分钟阅读"

@ -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 分鐘閱讀"

@ -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 -%}

@ -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 @@
</h1>
<ul class="meta">
{#- Draft indicator -#}
{% if page.draft %}
<li class="draft-label">{{ macros_translate::translate(key="draft", default="DRAFT", language_strings=language_strings) }}</li>
{% endif %}
{# page settings override config settings #}
{#- Author(s) -#}
{% if page.authors or config.author and macros_settings::evaluate_setting_priority(setting="show_author", page=page, default_global_value=false) == "true" %}
{%- if page.authors -%}
{%- set author_list = page.authors -%}
{%- else -%}
{%- set author_list = [config.author] -%}
{%- endif -%}
{%- if author_list | length == 1 -%}
{%- set author_string = author_list.0 -%}
{%- else -%}
{%- set last_author = author_list | last -%}
{%- set other_authors = author_list | slice(end=-1) -%}
{%- set author_separator = macros_translate::translate(key="author_separator", default=", ", language_strings=language_strings) -%}
{%- set conjunction = macros_translate::translate(key="author_conjunction", default=" and ", language_strings=language_strings) -%}
{%- set author_string = other_authors | join(sep=author_separator) -%}
{%- set author_string = author_string ~ conjunction ~ last_author -%}
{%- endif -%}
{%- set by_author = macros_translate::translate(key="by_author", default="By $AUTHOR", language_strings=language_strings) -%}
<li>{{ by_author | replace(from="$AUTHOR", to=author_string) }}</li>
{%- set previous_visible = true -%}
{% endif %}
{#- Date -#}
{% if page.date and macros_settings::evaluate_setting_priority(setting="show_date", page=page, default_global_value=true) == "true" %}
<li>{{ macros_format_date::format_date(date=page.date, short=true, language_strings=language_strings) }}</li>
{%- if previous_visible -%}&nbsp;{{ separator }}&nbsp;{%- endif -%}<li>{{ macros_format_date::format_date(date=page.date, short=true, language_strings=language_strings) }}</li>
{#- Variable to keep track of whether we've shown a section, to avoid separators as the first element -#}
{%- set previous_visible = true -%}
{% endif %}
{#- Reading time -#}
{% if macros_settings::evaluate_setting_priority(setting="show_reading_time", page=page, default_global_value=true) == "true" %}
{%- if previous_visible -%}{{ separator }}&nbsp;{%- endif -%}<li title="{{ macros_translate::translate(key="words", number=page.word_count, default="$NUMBER words", language_strings=language_strings) }}">{{ macros_translate::translate(key="min_read", number=page.reading_time, default="$NUMBER min read", language_strings=language_strings) }}</li>
{%- if previous_visible -%}&nbsp;{{ separator }}&nbsp;{%- endif -%}<li title="{{ macros_translate::translate(key="words", number=page.word_count, default="$NUMBER words", language_strings=language_strings) }}">{{ macros_translate::translate(key="min_read", number=page.reading_time, default="$NUMBER min read", language_strings=language_strings) }}</li>
{%- set previous_visible = true -%}
{% endif %}
{#- Tags -#}
{%- if page.taxonomies and page.taxonomies.tags -%}
{%- if previous_visible -%}&nbsp;{{ separator }}&nbsp;{%- endif -%}<li>{{- macros_translate::translate(key="tags", default="tags", language_strings=language_strings) | capitalize -}}:&nbsp;</li>
{%- for tag in page.taxonomies.tags -%}
@ -91,6 +119,7 @@
{%- set previous_visible = true -%}
{%- endif -%}
{#- Last updated on -#}
{% if page.updated %}
</ul><ul class="meta last-updated"><li>{{ macros_translate::translate(key="last_updated_on", default="Last updated on", language_strings=language_strings) }} {{ macros_format_date::format_date(date=page.updated, short=true, language_strings=language_strings) }}</li>
{# Show link to remote changes if enabled #}

@ -87,6 +87,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

Loading…
Cancel
Save