Skip to content

Commit

Permalink
links: handle links to not fully translated pages matcornic#377
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Oct 27, 2023
1 parent 8b0214e commit ff61932
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions layouts/partials/shortcodes/link.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit ff61932

Please sign in to comment.