diff --git a/config.toml b/config.toml index 91ac8fa..cf0ceb0 100644 --- a/config.toml +++ b/config.toml @@ -238,6 +238,16 @@ code_block_name_links = true compact_tags = false + +short_date_format = "" +# Per-language date format overrides. +# Examples: Spanish uses "3 de febrero de 2024", German uses "3. Februar 2024" +date_formats = [ + { lang = "ru", long = "%d %B %Y", short = "%-d %b %Y" }, + { lang = "en", long = "%d. %B %Y", short = "%d.%m.%Y" }, +] + + tag_sorting = "frequency" menu = [ diff --git a/themes/tabi/templates/macros/format_date.html b/themes/tabi/templates/macros/format_date.html index 3d22eba..f747fd1 100644 --- a/themes/tabi/templates/macros/format_date.html +++ b/themes/tabi/templates/macros/format_date.html @@ -3,7 +3,23 @@ {#- 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 -%} +{#- Check for language-specific date formats -#} +{%- set language_format = "" -%} +{%- if config.extra.date_formats -%} + {%- for format_config in config.extra.date_formats -%} + {%- if format_config.lang == lang -%} + {%- if short and format_config.short -%} + {%- set_global language_format = format_config.short -%} + {%- elif not short and format_config.long -%} + {%- set_global language_format = format_config.long -%} + {%- endif -%} + {%- endif -%} + {%- endfor -%} +{%- endif -%} + +{%- if language_format -%} + {{ date | date(format=language_format, locale=date_locale) }} +{%- elif 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 -%} {{ date | date(format=config.extra.long_date_format, locale=date_locale) }} diff --git a/themes/tabi/theme.toml b/themes/tabi/theme.toml index d9278aa..ab096f9 100644 --- a/themes/tabi/theme.toml +++ b/themes/tabi/theme.toml @@ -184,6 +184,14 @@ quick_navigation_buttons = false # Default is "6th July 2049" in English and "%-d %B %Y" in other languages. short_date_format = "" +# Per-language date format overrides. +# Examples: Spanish uses "3 de febrero de 2024", German uses "3. Februar 2024" +# date_formats = [ +# { lang = "es", long = "%d de %B de %Y", short = "%d %b %Y" }, +# { lang = "de", long = "%d. %B %Y", short = "%d.%m.%Y" }, +# ] + + # Custom separator used in title tag and posts metadata (between date, time to read, and tags). separator = "•"