blob: 0eaa9bd3025312df7e5c0a30216791d62710367f (
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
|
{{- $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 href="{{ $link | safeURL }}"
{{ with or .Title ($link | safeURL) -}}
title="{{ . }}"
{{ end }}
{{- if $remote -}}
data-external
rel="noopener no-referrer"
{{ end }}>{{- .Text | safeHTML -}}</a>
{{- /* This comment removes trailing newlines and white spaces. */ -}}
|