link: resolve fragments #775

This commit is contained in:
Sören Weber 2024-02-21 20:25:20 +01:00
parent 07542867aa
commit 4278578bda
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -16,7 +16,9 @@
{{- $u := urls.Parse $url }} {{- $u := urls.Parse $url }}
{{- $href := $u.String }} {{- $href := $u.String }}
{{- $path := $u.Path }} {{- $path := $u.Path }}
{{- if $u.IsAbs }} {{- if strings.HasPrefix $href "#" }}
{{- $href = printf "%s#%s" $page.Page.RelPermalink $u.Fragment }}
{{- else if $u.IsAbs }}
{{- $target = "_blank" }} {{- $target = "_blank" }}
{{- if isset $page.Site.Params "externallinktarget" }} {{- if isset $page.Site.Params "externallinktarget" }}
{{- $target = $page.Site.Params.externalLinkTarget }} {{- $target = $page.Site.Params.externalLinkTarget }}