aboutsummaryrefslogtreecommitdiff
path: root/generators/hugo/themes/tdro/layouts/_default/_markup/render-link.html
blob: 9ba80964a50879b370ac2b2b05b4c9900c9112a0 (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" .RelPermalink $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. */ -}}