blob: 00a6fd53b69b5429021d78950ad6ddf905907964 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
{{- $link := .Destination -}}
{{- $url := urls.Parse $link -}}
{{- $site := urls.Parse .Page.Site.BaseURL -}}
{{- $local := or (eq $url.Host $site.Host) (strings.HasPrefix $link "/") -}}
{{- $remote := not $local -}}
{{- if and $local $url.Path -}}
{{- $fragment := "" -}}
{{- with $url.Fragment -}}
{{- $fragment = printf "#%s" . -}}
{{- end -}}
{{- with .Page.GetPage $url.Path -}}
{{- $link = printf "%s%s" .Permalink $fragment -}}
{{- end -}}
{{- end -}}
<a
{{- if $remote }}
rel="noopener no-referrer"
{{- else }}
data-internal
{{- end }}
href="{{ $link | safeURL }}"
{{ with or .Title ($link | safeURL) -}}
title="{{ . }}"
{{ end }}>{{ .Text | safeHTML }}</a>
{{- /* This comment removes trailing newlines and white spaces. */ -}}
|