about summary refs log tree commit diff stats
path: root/templates
diff options
context:
space:
mode:
authorg4m42024-02-19 17:18:16 +0100
committerAlan Pearce2024-02-20 16:46:14 +0100
commit1c52ee3cc089e6b7ef8f38d1e6530b219239bd2e (patch)
treeda946895457ea2c68c1de66e023d223b1948e448 /templates
parentcfe243132912e9a21e7de990836380f4356ba92d (diff)
downloadzola-bearblog-1c52ee3cc089e6b7ef8f38d1e6530b219239bd2e.tar.lz
zola-bearblog-1c52ee3cc089e6b7ef8f38d1e6530b219239bd2e.tar.zst
zola-bearblog-1c52ee3cc089e6b7ef8f38d1e6530b219239bd2e.zip
Translation link now pointing to the translation of the current page
Diffstat (limited to 'templates')
-rw-r--r--templates/language_switcher.html7
1 files changed, 6 insertions, 1 deletions
diff --git a/templates/language_switcher.html b/templates/language_switcher.html
index b82ddfc..d3cd383 100644
--- a/templates/language_switcher.html
+++ b/templates/language_switcher.html
@@ -1,10 +1,15 @@
 {% if config.extra.language_switcher %}
   <nav>
+    {%- if current_path %}
+      {%- set language_agnostic_path=current_path | replace(from='/' ~ lang ~ '/', to = '/') | trim_start_matches(pat = '/')  -%}
+    {%- endif %}
     {%- for tr in config.extra.translations %}
       {%- if tr.code == lang %}
         <strong>{{ tr.name }}</strong>
       {%- else %}
-        <a href="{{ get_url(path="/", lang=tr.code) }}">{{ tr.name }}</a>
+        {%- if language_agnostic_path %}
+            <a href="{{ get_url(path=language_agnostic_path, lang=tr.code) }}">{{ tr.name }}</a>
+        {%- endif %}
       {%- endif %}
     {%- endfor %}
   </nav>