summaryrefslogtreecommitdiff
path: root/templates/partials/copyright.html
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2025-09-13 14:55:15 -0600
committerAlejandro Soto <alejandro@34project.org>2025-09-13 14:55:15 -0600
commita2ea06d513a5802964f8f0ef5795cec7e548ed7b (patch)
tree8afb58e3749d19bc46cffc6473f3059d647c515b /templates/partials/copyright.html
Squashed 'themes/tabi-lean/' content from commit 95c8796
git-subtree-dir: themes/tabi-lean git-subtree-split: 95c879696445ede40daa7a30a88dae5dd74d5c0c
Diffstat (limited to 'templates/partials/copyright.html')
-rw-r--r--templates/partials/copyright.html39
1 files changed, 39 insertions, 0 deletions
diff --git a/templates/partials/copyright.html b/templates/partials/copyright.html
new file mode 100644
index 0000000..b9cfc01
--- /dev/null
+++ b/templates/partials/copyright.html
@@ -0,0 +1,39 @@
+{%- if config.extra.copyright -%}
+ {% set copyright = config.extra.copyright %}
+ {# Try to look for a language-specific copyright notice in the new config setup #}
+ {%- if config.extra.copyright_translations -%}
+ {%- if lang in config.extra.copyright_translations -%}
+ {% set copyright = config.extra.copyright_translations[lang] %}
+ {%- endif -%}
+ {%- elif config.extra.translate_copyright -%}
+ {# Old way to translate the copyright through toml files #}
+ {{ throw(message="ERROR: The 'translate_copyright' feature has been deprecated. Please set 'copyright_translations' in config.toml. See the documentation: https://welpo.github.io/tabi/blog/mastering-tabi-settings/#copyright") }}
+ {%- endif -%}
+
+ {# Check for missing variables in the notice #}
+ {% set copyright_placeholders = ["$AUTHOR", "$TITLE"] %}
+ {% set missing_vars = [] %}
+ {% for placeholder in copyright_placeholders %}
+ {% if placeholder in copyright %}
+ {# Attempt to retrieve the corresponding variable by trimming the $ sign and converting to lowercase #}
+ {% set var_name = placeholder | replace(from="$", to="") | lower %}
+ {% if not config[var_name] %}
+ {# Append the variable name to the list of missing variables #}
+ {% set_global missing_vars = missing_vars | concat(with=var_name) %}
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+
+ {% if missing_vars | length > 0 %}
+ {% set missing_vars_str = missing_vars | join(sep=", ") %}
+ {{ throw(message="ERROR: The following variables are included in `copyright` but have not been set in the config.toml: " ~ missing_vars_str) }}
+ {% endif %}
+
+ {# At this point, we know that all variables needed defined, so we can safely override the missing ones #}
+ {% set author = config.author | default(value="") %}
+ {% set title = config.title | default(value="") %}
+
+ {# Render the copyright notice, replacing the variables #}
+ {% set current_year = now() | date(format="%Y") %}
+ <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 -%}