Skip to content

Commit

Permalink
🐛 fix(header): check if translations exist while building tags (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo authored Sep 16, 2023
1 parent ecaf0f1 commit 271f54c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions templates/partials/multilingual_tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 #}
Expand Down

0 comments on commit 271f54c

Please sign in to comment.