feat: add date visibility options to post list

Co-authored-by: sam <12381166+sam9032@users.noreply.github.com>
Co-authored-by: welpo <welpo@users.noreply.github.com>
This commit is contained in:
welpo 2024-07-09 23:18:58 +02:00
parent 57ff693eca
commit 313e573a3a
No known key found for this signature in database
GPG key ID: A2F978CF4EC1F5A6
10 changed files with 111 additions and 30 deletions

View file

@ -1,5 +1,7 @@
{% macro list_posts(posts, max, language_strings="", section_path="blog") %}
{%- set separator = config.extra.separator | default(value="•") -%}
<div class="bloglist-container">
{% for post in posts %}
{% if loop.index <= max %}
@ -12,9 +14,24 @@
{% endif %}
<ul class="bloglist-meta">
{% if post.date %}
<li class="date">{{ macros_format_date::format_date(date=post.date, short=false, language_strings=language_strings) }}</li>
{% endif %}
{%- set show_date = post.date and config.extra.post_listing_date == "date" or post.date and config.extra.post_listing_date == "both" -%}
{%- set show_updated = post.updated and config.extra.post_listing_date == "updated" or post.updated and config.extra.post_listing_date == "both" -%}
{%- if show_date or show_updated -%}
{%- if show_date -%}
<li class="date">{{- macros_format_date::format_date(date=post.date, short=false, language_strings=language_strings) -}}</li>
{%- endif -%}
{%- if show_date and show_updated -%}
<li class="mobile-only">{{- separator -}}</li>
{%- endif -%}
{%- if show_updated -%}
{%- set last_updated_str = macros_translate::translate(key="last_updated_on", default="Updated on $DATE", language_strings=language_strings) -%}
{%- set formatted_date = macros_format_date::format_date(date=post.updated, short=true, language_strings=language_strings) -%}
{%- set updated_str = last_updated_str | replace(from="$DATE", to=formatted_date) -%}
<li class="date">{{ updated_str }}</li>
{%- endif -%}
{%- endif -%}
{% if post.draft %}
<li class="draft-label">{{ macros_translate::translate(key="draft", default="DRAFT", language_strings=language_strings) }}</li>
{% endif %}