mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-11-10 08:12:11 +00:00
204600fae3
- No relative URLs in the RSS feed except plain anchor links - Eliminate the need for excessive "../" in URLs.
12 lines
781 B
XML
12 lines
781 B
XML
{{- $parsedDest := urls.Parse (.Destination | absURL) -}}
|
|
{{- if (strings.HasPrefix .Destination "#") -}}<!-- if it's a fragment -->
|
|
<a href="{{ .Destination }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>
|
|
{{- else if not (strings.HasPrefix .Destination $parsedDest.Scheme) -}}<!-- if it's a relative url -->
|
|
{{- $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 }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>
|
|
{{- end -}}
|