🐛 fix(header): check if translations exist while building tags

This commit is contained in:
welpo 2023-09-16 02:27:51 +02:00
parent ecaf0f1221
commit c74ab7d906
No known key found for this signature in database
GPG key ID: A2F978CF4EC1F5A6

View file

@ -16,10 +16,16 @@
{%- endif -%}
{%- set translated_filename = translated_filename ~ ".md" -%}
{%- if page.relative_path -%}
{%- set translated_page = get_page(path=translated_filename) -%}
{%- else -%}
{%- set translated_page = get_section(path=translated_filename) -%}
{# Check if the translated page or section exists #}
{%- set translation_exists = load_data(path=translated_filename, required=false) -%}
{# Get the page #}
{%- if translation_exists -%}
{%- if page.relative_path -%}
{%- set translated_page = get_page(path=translated_filename, metadata_only=true) -%}
{%- else -%}
{%- set translated_page = get_section(path=translated_filename, metadata_only=true) -%}
{%- endif -%}
{%- endif -%}
{# Create the og:locale and hreflang tags if the translated page exists #}