Merge pull request #25 from bedefaced/main

Current page detection & links of translations for multilingual mode
This commit is contained in:
Joe Roe 2022-09-30 13:23:04 +02:00 committed by GitHub
commit 2852ac6867
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 2 deletions

View file

@ -1,2 +1,29 @@
<p>
{{ $siteLanguages := .Site.Languages }}
{{ $pageLang := .Page.Lang }}
{{ $currentPage := . }}
{{ $pageName := "" }}
{{ range .Site.Menus.main }}
{{ if eq ($currentPage.Permalink) (.URL | absLangURL) }}
{{ $pageName = .Name }}
{{ end }}
{{ end }}
{{ range .Page.AllTranslations }}
{{ $translation := .}}
{{ range $siteLanguages }}
{{ if eq $translation.Lang .Lang }}
{{ $selected := false }}
{{ if eq $pageLang .Lang }}
<br/><span class="active">$ echo $LANG<br/><b>{{ .LanguageName }}</b></span><br/>
{{ else }}
<br/><a href="{{ $translation.Permalink }}">export LANG={{ .LanguageName }}; ./{{ $pageName }}</a><br/>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</p>
<br/><br/>
<p class="copyright">{{ .Site.Copyright }}</p> <p class="copyright">{{ .Site.Copyright }}</p>
<p class="advertisement">Powered by <a href="https://gohugo.io/">hugo</a> and <a href="https://github.com/joeroe/risotto">risotto</a>.</p> <p class="advertisement">Powered by <a href="https://gohugo.io/">hugo</a> and <a href="https://github.com/joeroe/risotto">risotto</a>.</p>

View file

@ -2,7 +2,7 @@
{{ with .Site.Params.about }}<meta name="description" content="{{ .description }}">{{ end }} {{ with .Site.Params.about }}<meta name="description" content="{{ .description }}">{{ end }}
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8"/> <meta charset="UTF-8"/>
{{ if .Site.Params.noindex }}<meta name="robots" content="noindex" /> {{ end }} {{ if .Site.Params.noindex }}<meta name="robots" content="noindex" /> {{ end }}
<!-- FontAwesome <https://fontawesome.com/> --> <!-- FontAwesome <https://fontawesome.com/> -->

View file

@ -3,7 +3,7 @@
<ul> <ul>
{{ $currentPage := . }} {{ $currentPage := . }}
{{ range .Site.Menus.main }} {{ range .Site.Menus.main }}
<li class="main-nav__item"><a class="nav-main-item{{if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} active{{end}}" href="{{ .URL }}" title="{{ .Title }}">{{ .Name }}</a></li> <li class="main-nav__item"><a class="nav-main-item{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) (eq ($currentPage.Permalink) (.URL | absLangURL)) }} active{{end}}" href="{{ .URL | absLangURL }}" title="{{ .Title }}">{{ .Name }}</a></li>
{{ end }} {{ end }}
</ul> </ul>
</nav> </nav>