✨ feat: allow custom archive date format (#557)
This commit is contained in:
@@ -240,14 +240,18 @@ code_block_name_links = true
|
|||||||
compact_tags = false
|
compact_tags = false
|
||||||
|
|
||||||
short_date_format = ""
|
short_date_format = ""
|
||||||
|
|
||||||
|
# Date format used for the archive page.
|
||||||
|
# Default is "06 July" in English and "%d %b" in other languages.
|
||||||
|
archive_date_format = ""
|
||||||
|
|
||||||
# Per-language date format overrides.
|
# Per-language date format overrides.
|
||||||
# Examples: Spanish uses "3 de febrero de 2024", German uses "3. Februar 2024"
|
# Examples: Spanish uses "3 de febrero de 2024", German uses "3. Februar 2024"
|
||||||
date_formats = [
|
date_formats = [
|
||||||
{ lang = "ru", long = "%d %B %Y", short = "%-d %b %Y" },
|
{ lang = "ru", long = "%d %B %Y", short = "%-d %b %Y", archive = "%d %b" },
|
||||||
{ lang = "en", long = "%d. %B %Y", short = "%d.%m.%Y" },
|
{ lang = "en", long = "%d. %B %Y", short = "%d.%m.%Y" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
tag_sorting = "frequency"
|
tag_sorting = "frequency"
|
||||||
|
|
||||||
menu = [
|
menu = [
|
||||||
|
|||||||
@@ -7,6 +7,18 @@
|
|||||||
{# Set locale for date #}
|
{# Set locale for date #}
|
||||||
{% set date_locale = macros_translate::translate(key="date_locale", default="en_GB", language_strings=language_strings) %}
|
{% set date_locale = macros_translate::translate(key="date_locale", default="en_GB", language_strings=language_strings) %}
|
||||||
|
|
||||||
|
{#- 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 format_config.archive -%}
|
||||||
|
{%- set_global language_format = format_config.archive -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endfor -%}
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
<div class="archive">
|
<div class="archive">
|
||||||
<ul class="list-with-title">
|
<ul class="list-with-title">
|
||||||
{%- set source_paths = section.extra.section_path | default(value="blog/") -%}
|
{%- set source_paths = section.extra.section_path | default(value="blog/") -%}
|
||||||
@@ -55,7 +67,13 @@
|
|||||||
<li class="listing-item">
|
<li class="listing-item">
|
||||||
<div class="post-time">
|
<div class="post-time">
|
||||||
<span class="date">
|
<span class="date">
|
||||||
|
{%- if language_format -%}
|
||||||
|
{{ post.date | date(format=language_format, locale=date_locale) }}
|
||||||
|
{%- elif config.extra.archive_date_format -%}
|
||||||
|
{{ post.date | date(format=config.extra.archive_date_format, locale=date_locale) }}
|
||||||
|
{%- else -%}
|
||||||
{{ post.date | date(format="%d %b", locale=date_locale) }}
|
{{ post.date | date(format="%d %b", locale=date_locale) }}
|
||||||
|
{%- endif -%}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<a href="{{ post.permalink }}" title="{{ post.title }}">{{ post.title | markdown(inline=true) | safe }}</a>
|
<a href="{{ post.permalink }}" title="{{ post.title }}">{{ post.title | markdown(inline=true) | safe }}</a>
|
||||||
|
|||||||
@@ -184,6 +184,11 @@ quick_navigation_buttons = false
|
|||||||
# Default is "6th July 2049" in English and "%-d %B %Y" in other languages.
|
# Default is "6th July 2049" in English and "%-d %B %Y" in other languages.
|
||||||
short_date_format = ""
|
short_date_format = ""
|
||||||
|
|
||||||
|
# Date format used for the archive page.
|
||||||
|
# Default is "06 July" in English and "%d %b" in other languages.
|
||||||
|
# archive_date_format = ""
|
||||||
|
|
||||||
|
|
||||||
# Per-language date format overrides.
|
# Per-language date format overrides.
|
||||||
# Examples: Spanish uses "3 de febrero de 2024", German uses "3. Februar 2024"
|
# Examples: Spanish uses "3 de febrero de 2024", German uses "3. Februar 2024"
|
||||||
# date_formats = [
|
# date_formats = [
|
||||||
|
|||||||
Reference in New Issue
Block a user