diff options
author | GNUxeava <bluenerd@protonmail.com> | 2022-03-11 10:32:10 +0530 |
---|---|---|
committer | GNUxeava <bluenerd@protonmail.com> | 2022-03-11 10:32:10 +0530 |
commit | fecc9b268410c8fefcd1ca32bc4228bba9002178 (patch) | |
tree | aa621093976dbbe8961f723ddb3569737e96932a /layouts/partials/header | |
parent | 2dfa39111cd76b102dbb3f58c1754b6c93b0265a (diff) |
use theme
Diffstat (limited to 'layouts/partials/header')
-rw-r--r-- | layouts/partials/header/language-selector.html | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/layouts/partials/header/language-selector.html b/layouts/partials/header/language-selector.html new file mode 100644 index 0000000..e28650e --- /dev/null +++ b/layouts/partials/header/language-selector.html @@ -0,0 +1,25 @@ +<!-- + Language selector. + + If current page has version in another language, language link will lead + to the translated page. If not, the link will be to the home page of the site + with specified language. +--> +{{ if (and (.Site.IsMultiLingual) ($.Site.Params.showLanguageSelector)) }} + <div class="language-selector"> + <ul class="languages-list"> + {{ range $homeTranslation := .Site.Home.AllTranslations }} + {{ $active := eq $homeTranslation.Language $.Site.Language }} + {{ $pageTranslation := (index (where $.Page.AllTranslations "Language.Lang" "eq" $homeTranslation.Language.Lang) 0) }} + + <li class="language-item {{if $active}}active{{end}}"> + {{ with $pageTranslation }} + <a href="{{ .Permalink }}">{{ .Language.Lang }}</a> + {{ else }} + <a href="{{ $homeTranslation.Permalink }}">{{ .Language.Lang }}</a> + {{ end }} + </li> + {{ end }} + </ul> + </div> +{{ end }} |