all repos — zola-bearblog @ 99423f57f79499f13d021970c1efb4529072006b

Port of bear blog theme to zola

templates/language_switcher.html (view raw)

1
2
3
4
5
6
7
8
9
10
11
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 %}
        <active>{{ tr.name }}</active>
      {%- else %}
          <a href="{{ get_url(path=language_agnostic_path, lang=tr.code) ~ "/" }}" hreflang="{{ tr.code }}">{{ tr.name }}</a>
      {%- endif %}
    {%- endfor %}
  </nav>
{%- endif -%}