theme: fix multilang links when site served from subdirectory #370

This commit is contained in:
Sören Weber 2022-11-05 23:57:11 +01:00
parent 460ab79e66
commit b9e97bcc0b
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
2 changed files with 2 additions and 5 deletions

View file

@ -76,9 +76,9 @@
{{- range $siteLanguages }}
{{- if eq $translation.Lang .Lang }}
{{- if eq $pageLang .Lang }}
<option lang="{{ $translation.Lang }}" id="{{ $translation.Lang }}" value="{{ partial "relLangPrettyUglyURL.hugo" (dict "page" $page "to" $translation "isTranslation" true) }}" selected>{{ .LanguageName }}</option>
<option lang="{{ $translation.Lang }}" id="{{ $translation.Lang }}" value="{{ partial "relLangPrettyUglyURL.hugo" (dict "page" $page "to" $translation) }}" selected>{{ .LanguageName }}</option>
{{- else }}
<option lang="{{ $translation.Lang }}" id="{{ $translation.Lang }}" value="{{ partial "relLangPrettyUglyURL.hugo" (dict "page" $page "to" $translation "isTranslation" true) }}">{{ .LanguageName }}</option>
<option lang="{{ $translation.Lang }}" id="{{ $translation.Lang }}" value="{{ partial "relLangPrettyUglyURL.hugo" (dict "page" $page "to" $translation) }}">{{ .LanguageName }}</option>
{{- end }}
{{- end }}
{{- end }}

View file

@ -1,9 +1,6 @@
{{- $page := .page }}
{{- $to := .to }}
{{- $link := $to.RelPermalink }}
{{- if not .isTranslation }}
{{- $link = $link | relLangURL }}
{{- end }}
{{- if and .page.Site.Params.uglyURLs (eq (substr $link -1) "/") }}
{{- $link = printf "%sindex.html" $link }}
{{- end }}