feat(copyright): support no title or author config

title and auhtor are optional in config.toml and the `replace`
function doesn't support 'null' value in the `to` argument.
This commit is contained in:
ZzMzaw 2023-11-02 21:54:18 +01:00
parent d27681a5c4
commit 5111fe0149

View file

@ -88,6 +88,8 @@
<small>
{# Shows optional Copyright notice #}
{%- if config.extra.copyright -%}
{% set author = config.author | default(value="") %}
{% set title = config.title | default(value="") %}
{% set current_year = now() | date(format="%Y") %}
{% set copyright = config.extra.copyright %}
@ -104,7 +106,7 @@
{%- endif -%}
{# Render the copyright notice, replacing the variables #}
<p>{{ copyright | replace(from="$AUTHOR", to=config.author) | replace(from="$TITLE", to=config.title) | replace(from="$CURRENT_YEAR", to=current_year) | replace(from="$SEPARATOR", to=separator) | markdown | safe }}</p>
<p>{{ copyright | replace(from="$AUTHOR", to=author) | replace(from="$TITLE", to=title) | replace(from="$CURRENT_YEAR", to=current_year) | replace(from="$SEPARATOR", to=separator) | markdown | safe }}</p>
{%- endif -%}
{# Shows "Powered by Zola & tabi" notice #}