clean up render-link template, add rel=external attr

This commit is contained in:
John Bowdre 2024-06-28 22:53:52 -05:00
parent 25e4274986
commit 9c6da303a9

View file

@ -1 +1,9 @@
<a href="{{ .Destination | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}{{ if strings.HasPrefix .Destination "http" }}↗{{ end }}</a>
{{- $u := urls.Parse .Destination -}}
<a href="{{ .Destination | safeURL }}"
{{- with .Title }} title="{{ . }}"{{ end -}}
{{- if $u.IsAbs }} rel="external"{{ end -}}
>
{{- with .Text | safeHTML }}{{ . }}{{ end -}}
{{- if $u.IsAbs }}↗{{ end -}}
</a>
{{- /* chomp trailing newline */ -}}