about summary refs log tree commit diff stats
path: root/templates/nav.html
diff options
context:
space:
mode:
authorAlan Pearce2024-02-20 20:02:36 +0000
committerAlan Pearce2024-02-20 20:02:36 +0000
commit333e97f135264c3c220063b2b64bf4dc0b508f34 (patch)
treefda555ec02ad606d42d089b01107cbfead01f68d /templates/nav.html
parent5a936b5c413b541c5523da6b4ebdc46f996f7360 (diff)
parentfa345b1d1e11cc66ed92605382887fd4367ef97a (diff)
downloadzola-bearblog-333e97f135264c3c220063b2b64bf4dc0b508f34.tar.lz
zola-bearblog-333e97f135264c3c220063b2b64bf4dc0b508f34.tar.zst
zola-bearblog-333e97f135264c3c220063b2b64bf4dc0b508f34.zip
Merge pull request 'Basic multilingual site' (#10) from multilingual into main
Reviewed-on: https://codeberg.org/alanpearce/zola-bearblog/pulls/10
Diffstat (limited to 'templates/nav.html')
-rw-r--r--templates/nav.html16
1 files changed, 14 insertions, 2 deletions
diff --git a/templates/nav.html b/templates/nav.html
index a71652e..ba9f543 100644
--- a/templates/nav.html
+++ b/templates/nav.html
@@ -1,9 +1,21 @@
+{% set current_lang = config.default_language %}
+{% if page %}
+  {% set current_lang = page.lang %}
+{% elif section %}
+  {% set current_lang = section.lang %}
+{% endif %}
 {%- if config.extra.main_menu %}
   {%- for item in config.extra.main_menu %}
+    {% if current_lang == config.default_language %}
+      {% set title = item.name %}
+    {% else %}
+      {% set language_key = 'name_' ~ current_lang %}
+      {% set title = item[language_key] %}
+    {% endif %}
     {%- if item.url is matching("https?://") %}
-      <a href="{{ item.url }}">{{ item.name }}</a>
+      <a href="{{ item.url }}">{{ title }}</a>
     {%- else %}
-      <a href="{{ get_url(path=item.url, lang=lang )}}">{{ item.name }}</a>
+      <a href="{{ get_url(path=item.url, lang=lang )}}">{{ title }}</a>
     {%- endif %}
   {%- endfor %}
 {%- endif -%}