hugo-theme-terminal/layouts/partials/language-menu.html
Rui Miguel Silva Seabra 45ed0606ad Make menus:
1. Not repeat the current page language
2. point to the same page in the other languages rather than to the web site's root
2022-12-02 02:02:40 +00:00

22 lines
883 B
HTML

{{ $currentpage := .Page }}
<ul class="menu menu--desktop menu--language-selector">
<li class="menu__trigger">{{ .Language.LanguageName }}&nbsp;</li>
<li>
<ul class="menu__dropdown">
{{ range $.Site.Home.AllTranslations }}
{{ if ne .Lang $currentpage.Language.Lang }}
{{ if eq .Lang $.Site.Params.DefaultContentLanguage }}
<li><a href="{{ strings.Substr $currentpage.RelPermalink 3 }}">{{ .Language.LanguageName }}</a></li>
{{ else }}
{{ if eq $currentpage.Language.Lang $.Site.Params.DefaultContentLanguage }}
<li><a href="/{{ .Lang }}{{ $currentpage.RelPermalink }}">{{ .Language.LanguageName }}</a></li>
{{ else }}
<li><a href="/{{ .Lang }}{{ substr $currentpage.RelPermalink 3 }}">{{ .Language.LanguageName }}</a></li>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</ul>
</li>
</ul>