aboutsummaryrefslogtreecommitdiff
path: root/layouts/_markup/render-link.html
blob: bb507d24fdab3e8c772aaa6363eea6fcc27dddce3e6e800b48e44fcdb4c17a17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
{{ $emoji := cond (and (not (.Page.Params.makerefs | default true)) (.Page.Params.showlinkemoji | default true)) (emojify ":link: ") "" -}}
{{ $isExternalLink := (urls.Parse .Destination).IsAbs -}}

{{/* .Destination is marked safe below so that schemes the web knows nothing */ -}}
{{/* about, such as gemini://, survive; scripting schemes are dropped instead */ -}}
{{ $scheme := lower (urls.Parse .Destination).Scheme -}}
{{ if in (slice "javascript" "vbscript" "data") $scheme -}}
{{ warnidf "unsafe-link-scheme" "dropped %s: link in %s" $scheme .Page.Path -}}
{{ .Text -}}
{{ else -}}
{{ $emoji }}<a class="link {{ if $isExternalLink }}link--external{{ else }}link--internal{{ end }}" href="{{ .Destination | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }} rel="{{ if $isExternalLink }}external {{ end }}noreferrer">{{ .Text }}</a>
{{- end -}}