mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-26 08:30:54 +00:00
b893a09aa6
Closes #12514
29 lines
874 B
HTML
29 lines
874 B
HTML
{{- $u := urls.Parse .Destination -}}
|
|
{{- $href := $u.String -}}
|
|
{{- if strings.HasPrefix $u.String "#" }}
|
|
{{- $href = printf "%s#%s" .PageInner.RelPermalink $u.Fragment }}
|
|
{{- else if not $u.IsAbs -}}
|
|
{{- $path := strings.TrimPrefix "./" $u.Path }}
|
|
{{- with or
|
|
($.PageInner.GetPage $path)
|
|
($.PageInner.Resources.Get $path)
|
|
(resources.Get $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 | transform.HTMLEscape) -}}
|
|
<a
|
|
{{- range $k, $v := $attributes -}}
|
|
{{- if $v -}}
|
|
{{- printf " %s=%q" $k $v | safeHTMLAttr -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
>{{ .Text | safeHTML }}</a>
|
|
{{- /**/ -}}
|