aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/_default/_markup/render-link.html
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/layouts/_default/_markup/render-link.html')
-rw-r--r--themes/default/layouts/_default/_markup/render-link.html21
1 files changed, 21 insertions, 0 deletions
diff --git a/themes/default/layouts/_default/_markup/render-link.html b/themes/default/layouts/_default/_markup/render-link.html
new file mode 100644
index 0000000..9b1ffae
--- /dev/null
+++ b/themes/default/layouts/_default/_markup/render-link.html
@@ -0,0 +1,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
+ rel="noopener"
+ href="{{ $link | safeURL }}"
+ {{ with or .Title ($link | safeURL) -}}
+ title="{{ . }}"
+ {{ end }}
+ {{- if $isRemote -}}
+ target="_blank"
+ {{ end }}>
+ {{- .Text | safeHTML -}}
+</a>
+{{- /* This comment removes trailing newlines and white spaces. */ -}}