mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-11-14 17:42:09 +00:00
429dcda2cd
This works particularly well on my Atom feeds with embedded XHTML.
12 lines
729 B
XML
12 lines
729 B
XML
{{- $parsedDest := urls.Parse (.Destination | absURL) -}}
|
|
{{- if (strings.HasPrefix .Destination "#") -}}
|
|
<a href="{{ .Destination }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>
|
|
{{- else if not (strings.HasPrefix .Destination $parsedDest.Scheme) -}}
|
|
{{- $baseURL := trim .Page.Site.BaseURL "/" -}}
|
|
{{- $fragment := "" -}}
|
|
{{- with $parsedDest.Fragment -}}{{- $fragment = printf "#%s" . -}}{{- end -}}
|
|
{{- $href := printf "%s%s%s" $baseURL $parsedDest.Path $fragment | absURL -}}
|
|
<a href="{{ $href }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>
|
|
{{- else -}}
|
|
<a href="{{ .Destination | htmlEscape }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>
|
|
{{- end -}}
|