about summary refs log tree commit diff stats
path: root/templates/language_switcher.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/language_switcher.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/language_switcher.html')
-rw-r--r--templates/language_switcher.html12
1 files changed, 12 insertions, 0 deletions
diff --git a/templates/language_switcher.html b/templates/language_switcher.html
new file mode 100644
index 0000000..3968c73
--- /dev/null
+++ b/templates/language_switcher.html
@@ -0,0 +1,12 @@
+{% if config.extra.language_switcher %}
+  <nav class="lang">
+    {%- set language_agnostic_path = current_path | default(value="/") | replace(from='/' ~ lang ~ '/', to = '/') | trim_start_matches(pat = '/') -%}
+    {%- for tr in config.extra.translations %}
+      {%- if tr.code == lang %}
+        <strong>{{ tr.name }}</strong>
+      {%- else %}
+          <a href="{{ get_url(path=language_agnostic_path, lang=tr.code) ~ "/" }}" hreflang="{{ tr.code }}">{{ tr.name }}</a>
+      {%- endif %}
+    {%- endfor %}
+  </nav>
+{% endif %}