Skip to content

Commit

Permalink
✨ feat: add option to show author in post metadata (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo authored May 27, 2024
1 parent 86a4e5f commit 9d49a65
Show file tree
Hide file tree
Showing 24 changed files with 157 additions and 39 deletions.
4 changes: 4 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion content/blog/mastering-tabi-settings/index.ca.md
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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 |
Expand Down
12 changes: 11 additions & 1 deletion content/blog/mastering-tabi-settings/index.es.md
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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 |
Expand Down
12 changes: 11 additions & 1 deletion content/blog/mastering-tabi-settings/index.md
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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 |
Expand Down
3 changes: 3 additions & 0 deletions i18n/ar.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions i18n/ca.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions i18n/de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions i18n/es.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions i18n/fa.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 دقیقه"
Expand Down
3 changes: 3 additions & 0 deletions i18n/fr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions i18n/hi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 मिनट पठन समय"
Expand Down
3 changes: 3 additions & 0 deletions i18n/it.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions i18n/ja.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 分の読了時間"
Expand Down
3 changes: 3 additions & 0 deletions i18n/ko.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 분 읽기"
Expand Down
3 changes: 3 additions & 0 deletions i18n/nl.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions i18n/pt-PT.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions i18n/ru.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 мин чтения"
Expand Down
3 changes: 3 additions & 0 deletions i18n/uk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 хв. читання"
Expand Down
3 changes: 3 additions & 0 deletions i18n/zh-Hans.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 分钟阅读"
Expand Down
3 changes: 3 additions & 0 deletions i18n/zh-Hant.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 分鐘閱讀"
Expand Down
66 changes: 33 additions & 33 deletions templates/macros/format_date.html
Original file line number Diff line number Diff line change
@@ -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 -%}
Loading

0 comments on commit 9d49a65

Please sign in to comment.