link: adjust to Hugo's build-in render hook #824

This commit is contained in:
Sören Weber 2024-04-07 13:44:48 +02:00
parent 0385a06f45
commit 86b53ec26c
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -17,6 +17,7 @@
{{- $href := $u.String }}
{{- $path := $u.Path }}
{{- if $u.IsAbs }}
{{- $attributes = merge $attributes (dict "rel" "external") }}
{{- $target = "_blank" }}
{{- if isset $page.Site.Params "externallinktarget" }}
{{- $target = $page.Site.Params.externalLinkTarget }}
@ -27,7 +28,9 @@
{{- if $path }}
{{- with or
($page.Page.GetPage $path)
($page.Page.GetPage (strings.TrimRight "/" $path))
($page.Page.Resources.Get $path)
(and (ne $page.Page.BundleType "leaf") ($page.Page.CurrentSection.Resources.Get $path))
(resources.Get $path)
}}
{{- $linkPage = . }}
@ -44,7 +47,9 @@
{{- if and (strings.HasPrefix $path $prefix) (strings.HasPrefix $suffix "/") }}
{{- with or
(.GetPage $suffix)
(.GetPage (strings.TrimRight "/" $suffix))
(.Resources.Get $suffix)
(and (ne .BundleType "leaf") (.CurrentSection.Resources.Get $suffix))
(resources.Get $suffix)
}}
{{- $linkPage = . }}