link: fix build error for multilang environments #789

This commit is contained in:
Sören Weber 2024-03-04 21:04:07 +01:00
parent c557b051f7
commit d81b4dd6eb
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -34,10 +34,13 @@
{{- else }} {{- else }}
{{- /* is it a link into another translation? */}} {{- /* is it a link into another translation? */}}
{{- if strings.HasPrefix $path "/" }} {{- if strings.HasPrefix $path "/" }}
{{- range $page.Sites }} {{- range $page.AllTranslations }}
{{- $lang := .Language.Lang }} {{- $lang := .Language.Lang }}
{{- $prefix := printf "/%s" $lang }} {{- $prefix := printf "/%s" $lang }}
{{- $suffix := strings.TrimPrefix $prefix $path | default "/" }} {{- $suffix := strings.TrimPrefix $prefix $path | default "/" }}
{{- /* with the second check we check if the prefix was finished;
eg. /pir/index.html vs. /pirate/index.html, were the latter is
an external address outside of this site */}}
{{- if and (strings.HasPrefix $path $prefix) (strings.HasPrefix $suffix "/") }} {{- if and (strings.HasPrefix $path $prefix) (strings.HasPrefix $suffix "/") }}
{{- with or {{- with or
(.GetPage $suffix) (.GetPage $suffix)