From ff61932b700fb11d5ac2325fa62ee896a560ab63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sat, 28 Oct 2023 00:37:39 +0200 Subject: [PATCH] links: handle links to not fully translated pages #377 --- layouts/partials/shortcodes/link.html | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/layouts/partials/shortcodes/link.html b/layouts/partials/shortcodes/link.html index eff8342d64..73cb7c2506 100644 --- a/layouts/partials/shortcodes/link.html +++ b/layouts/partials/shortcodes/link.html @@ -31,18 +31,14 @@ {{- $found = true }} {{- else }} {{- /* is it a link into another translation? */}} - {{- range $page.Site.Languages }} - {{- $lang := .Lang }} + {{- range $page.Sites }} + {{- $lang := .Language.Lang }} {{- $prefix := printf "%s/" $lang }} {{- if strings.HasPrefix $path $prefix }} {{- $path = strings.TrimPrefix $prefix $path | default "/" }} - {{- with $page.Site.GetPage (strings.TrimSuffix "/" $path | default "/") }} - {{- range .Page.AllTranslations }} - {{- if eq $lang .Lang }} - {{- $url = printf "%s%s" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) $fragment }} - {{- $found = true }} - {{- end }} - {{- end }} + {{- with .GetPage (strings.TrimSuffix "/" $path | default "/") }} + {{- $url = printf "%s%s" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) $fragment }} + {{- $found = true }} {{- end }} {{- end }} {{- end }}