mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
c9f7ebf004
Fixes #12084
28 lines
790 B
HTML
28 lines
790 B
HTML
{{- $u := urls.Parse .Destination -}}
|
|
{{- $href := $u.String -}}
|
|
{{- if strings.HasPrefix $u.String "#" }}
|
|
{{- $href = printf "%s#%s" .Page.RelPermalink $u.Fragment }}
|
|
{{- else if not $u.IsAbs -}}
|
|
{{- with or
|
|
($.Page.GetPage $u.Path)
|
|
($.Page.Resources.Get $u.Path)
|
|
(resources.Get $u.Path)
|
|
-}}
|
|
{{- $href = .RelPermalink -}}
|
|
{{- with $u.RawQuery -}}
|
|
{{- $href = printf "%s?%s" $href . -}}
|
|
{{- end -}}
|
|
{{- with $u.Fragment -}}
|
|
{{- $href = printf "%s#%s" $href . -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- $attributes := dict "href" $href "title" .Title -}}
|
|
<a
|
|
{{- range $k, $v := $attributes -}}
|
|
{{- if $v -}}
|
|
{{- printf " %s=%q" $k $v | safeHTMLAttr -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
>{{ .Text | safeHTML }}</a>
|
|
{{- /**/ -}}
|