2024-01-30 10:43:20 +00:00
|
|
|
{{- $u := urls.Parse .Destination -}}
|
|
|
|
{{- $href := $u.String -}}
|
2024-02-21 01:57:51 +00:00
|
|
|
{{- if strings.HasPrefix $u.String "#" }}
|
2024-04-11 15:46:18 +00:00
|
|
|
{{- $href = printf "%s#%s" .PageInner.RelPermalink $u.Fragment }}
|
2024-02-21 01:57:51 +00:00
|
|
|
{{- else if not $u.IsAbs -}}
|
2024-05-17 22:41:18 +00:00
|
|
|
{{- $path := strings.TrimPrefix "./" $u.Path }}
|
2024-01-30 10:43:20 +00:00
|
|
|
{{- with or
|
2024-05-17 22:41:18 +00:00
|
|
|
($.PageInner.GetPage $path)
|
|
|
|
($.PageInner.Resources.Get $path)
|
|
|
|
(resources.Get $path)
|
2024-01-30 10:43:20 +00:00
|
|
|
-}}
|
|
|
|
{{- $href = .RelPermalink -}}
|
|
|
|
{{- with $u.RawQuery -}}
|
|
|
|
{{- $href = printf "%s?%s" $href . -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- with $u.Fragment -}}
|
|
|
|
{{- $href = printf "%s#%s" $href . -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
2024-04-22 08:56:02 +00:00
|
|
|
{{- $attributes := dict "href" $href "title" (.Title | transform.HTMLEscape) -}}
|
2024-01-30 10:43:20 +00:00
|
|
|
<a
|
|
|
|
{{- range $k, $v := $attributes -}}
|
|
|
|
{{- if $v -}}
|
|
|
|
{{- printf " %s=%q" $k $v | safeHTMLAttr -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
>{{ .Text | safeHTML }}</a>
|
|
|
|
{{- /**/ -}}
|