aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/_default/_markup/render-link.html
blob: ccfbc0609e1053e38e7369c19573eb665ec2c4ad (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. */ -}}