aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/_default/_markup/render-link.html
blob: 17a6f2cfb630297fc51fa9c0ed2b34e0639fc364 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{{- $link := .Destination -}}
{{ $isRemote := strings.HasPrefix $link "http" }}
{{- if not $isRemote -}}
{{ $url := urls.Parse .Destination }}
{{- if $url.Path -}}
{{ $fragment := "" }}
{{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}}
{{- with .Page.GetPage $url.Path }}{{ $link = printf "%s%s" .Permalink $fragment }}{{ end }}{{ end -}}
{{- end -}}
<a
  href="{{ $link | safeURL }}"
  {{ with or .Title ($link | safeURL) -}}
  title="{{ . }}"
  {{ end }}
  {{- if $isRemote -}}
  target="_blank"
  rel="noopener no-referrer"
  {{ end }}>
    {{- .Text | safeHTML -}}
</a>
{{- /* This comment removes trailing newlines and white spaces. */ -}}