Fix language menu in multihost setting
#196 added the flexibility to index.html to be used in subdirectories. Unfortunately this broke the language menu in multihost settings. Both functionalities are made to work now by checking the `hugo.IsMultihost` condition. This makes the code somewhat harder to read, but at least ensures that the regression is fixed. Fixes: #214 Signed-off-by: Daniel Holbach <daniel.holbach@gmail.com>
This commit is contained in:
parent
d326aa747e
commit
811e1f2b54
2 changed files with 26 additions and 7 deletions
|
|
@ -1,9 +1,15 @@
|
||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
{{ $headless := .GetPage "./homepage" }}
|
{{ $headless := .GetPage "./homepage" }}
|
||||||
|
{{ if hugo.IsMultihost }}
|
||||||
|
{{ $headless := .Site.GetPage "/homepage" }}
|
||||||
|
{{ end }}
|
||||||
{{ $sections := $headless.Resources.ByType "page" }}
|
{{ $sections := $headless.Resources.ByType "page" }}
|
||||||
{{ $sections := cond .Site.BuildDrafts $sections (where $sections "Draft" "==" false) }}
|
{{ $sections := cond .Site.BuildDrafts $sections (where $sections "Draft" "==" false) }}
|
||||||
{{ $content := where (where $sections "Params.external" "==" nil) "Params.detailed_page_homepage_content" "ne" false }}
|
{{ $content := where (where $sections "Params.external" "==" nil) "Params.detailed_page_homepage_content" "ne" false }}
|
||||||
{{ $translations := .Page.AllTranslations }}
|
{{ $langs := .Page.AllTranslations }}
|
||||||
|
{{ if hugo.IsMultihost }}
|
||||||
|
{{ $langs = .Site.Languages }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<!-- Welcome screen that scrolls out of view -->
|
<!-- Welcome screen that scrolls out of view -->
|
||||||
{{ if not .Params.header_use_video }}
|
{{ if not .Params.header_use_video }}
|
||||||
|
|
@ -60,17 +66,26 @@
|
||||||
{{- partial "custom_header_video.html" . -}}
|
{{- partial "custom_header_video.html" . -}}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ $num_lang := len $translations }}
|
{{ $num_lang := len $langs }}
|
||||||
{{ if and (gt $num_lang 1) $.Site.Params.language_menu }}
|
{{ if and (gt $num_lang 1) $.Site.Params.language_menu }}
|
||||||
<div id="site-languages" class="inner">
|
<div id="site-languages" class="inner">
|
||||||
{{ range $translations }}
|
{{ range $langs }}
|
||||||
{{ $lang_title := or .Language.LanguageName (.Lang | strings.ToUpper) }}
|
{{ $condition := eq .Lang $.Lang }}
|
||||||
{{ if eq .Lang $.Lang }}
|
{{ $lang_func := .Language.LanguageName }}
|
||||||
|
{{ $href := .RelPermalink }}
|
||||||
|
{{ if hugo.IsMultihost }}
|
||||||
|
{{ $langs = site.Sites }}
|
||||||
|
{{ $condition = eq . $.Site }}
|
||||||
|
{{ $lang_func = .LanguageName }}
|
||||||
|
{{ $href = .Home.Permalink }}
|
||||||
|
{{ end }}
|
||||||
|
{{ $lang_title := or $lang_func (.Lang | strings.ToUpper) }}
|
||||||
|
{{ if $condition }}
|
||||||
{{ if $.Site.Params.show_current_lang }}
|
{{ if $.Site.Params.show_current_lang }}
|
||||||
<span class='btn-lang active'>{{ $lang_title }}</span>
|
<span class='btn-lang active'>{{ $lang_title }}</span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<a class='btn-lang' href='{{ .RelPermalink }}'>{{ $lang_title }}</a>
|
<a class='btn-lang' href='{{ $href }}'>{{ $lang_title }}</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,11 @@
|
||||||
<article class="post page">
|
<article class="post page">
|
||||||
<header class="post-header">
|
<header class="post-header">
|
||||||
{{ with .Parent }}
|
{{ with .Parent }}
|
||||||
|
{{ if hugo.IsMultihost }}
|
||||||
<a id="back-to-main-page" href="{{ .RelPermalink | relLangURL }}"><i class="fa fa-chevron-left" aria-hidden="true"></i> {{ or .Title .Site.Title }}</a>
|
<a id="back-to-main-page" href="{{ .RelPermalink | relLangURL }}"><i class="fa fa-chevron-left" aria-hidden="true"></i> {{ or .Title .Site.Title }}</a>
|
||||||
|
{{ else }}
|
||||||
|
<a id="back-to-main-page" href="{{ .RelPermalink | relLangURL }}"><i class="fa fa-chevron-left" aria-hidden="true"></i> {{ or .Title .Site.Title }}</a>
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</header>
|
</header>
|
||||||
<h1 class="post-title">{{ .Title }}</h1>
|
<h1 class="post-title">{{ .Title }}</h1>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue