Add a language switcher bar below the navbar

This commit is contained in:
BBaoVanC 2021-10-11 21:26:23 -05:00
parent 47adfd5f7d
commit 7276be72e9
Signed by: bbaovanc
GPG Key ID: 18089E4E3CCF1D3A
2 changed files with 21 additions and 3 deletions

View File

@ -68,12 +68,16 @@
/* Navbar formatting */ /* Navbar formatting */
#navbar h2 { .navbar, .langbar {
margin: 5px 0px;
}
(.navbar, .langbar) h2 {
color: inherit; color: inherit;
text-decoration: inherit; text-decoration: inherit;
} }
.navbar-item { .navbar-item, .langbar-item {
margin-right: 5px; margin-right: 5px;
} }

View File

@ -2,7 +2,7 @@
<a href="{{ "/" | relURL }}">{{ .Site.Title | markdownify }}</a> <a href="{{ "/" | relURL }}">{{ .Site.Title | markdownify }}</a>
</h2> </h2>
<nav id="navbar"> <nav class="navbar">
{{ with .Site.GetPage "/" }} {{ with .Site.GetPage "/" }}
{{/* if I use relLangURL, then it does /es/es/ instead of /es/ (for example) */}} {{/* if I use relLangURL, then it does /es/es/ instead of /es/ (for example) */}}
<a class="navbar-item" href="{{ .Permalink | relURL }}">{{ .Title }}</a> <a class="navbar-item" href="{{ .Permalink | relURL }}">{{ .Title }}</a>
@ -12,3 +12,17 @@
<a class="navbar-item" href="{{ .URL }}">{{ .Name }}</a> <a class="navbar-item" href="{{ .URL }}">{{ .Name }}</a>
{{ end }} {{ end }}
</nav> </nav>
{{ if .Site.IsMultiLingual }}
<nav class="langbar">
{{ range .Site.Home.AllTranslations }}
{{ if eq .Language $.Site.Language }}
<b><a class="langbar-item" href="{{ .Permalink }}">{{ .Language.LanguageName }}</a></b>
{{ else }}
<a class="langbar-item" href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
{{ end }}
{{ end }}
</nav>
{{ end }}