Skip to content

Commit

Permalink
validate settings + use 'date' by default + mention default in comments
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo committed Jul 11, 2024
1 parent f3946dc commit 77a4b5f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ show_reading_time = true
show_date = true

# Determines how dates are displayed in the post listing (e.g. front page or /blog). Options:
# "date" - Show only the original date of the post.
# "date" - Show only the original date of the post (default if unset).
# "updated" - Show only the last updated date of the post.
# "both" - Show both the original date and the last updated date.
post_listing_date = "both"
post_listing_date = "date"

# DEPRECATED!
# Use Zola's built-in `bottom_footnotes = true` in the [markdown] section instead. (Available since v0.19.0)
Expand Down
10 changes: 8 additions & 2 deletions templates/macros/list_posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
{% endif %}

<ul class="bloglist-meta">
{%- 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" -%}
{%- set allowed_post_listing_dates = ["date", "updated", "both"] -%}
{%- set post_listing_date = config.extra.post_listing_date | default(value="date") -%}
{%- if post_listing_date not in allowed_post_listing_dates -%}
{{ throw(message="ERROR: Invalid value for config.extra.post_listing_date. Allowed values are 'date', 'updated', or 'both'.") }}
{%- endif -%}

{%- set show_date = post.date and post_listing_date == "date" or post.date and post_listing_date == "both" -%}
{%- set show_updated = post.updated and post_listing_date == "updated" or post.updated and post_listing_date == "both" -%}

{%- if show_date or show_updated -%}
{%- if show_date -%}
Expand Down
2 changes: 1 addition & 1 deletion theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ show_reading_time = true
show_date = true

# Determines how dates are displayed in the post listing (e.g. front page or /blog). Options:
# "date" - Show only the original date of the post.
# "date" - Show only the original date of the post (default if unset).
# "updated" - Show only the last updated date of the post.
# "both" - Show both the original date and the last updated date.
post_listing_date = "date"
Expand Down

0 comments on commit 77a4b5f

Please sign in to comment.