Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit 6f7ce8e

Browse files
authored
Render links with given destination w/o rewriting (#98)
Signed-off-by: Patrice Chalin <[email protected]>
1 parent deed88e commit 6f7ce8e

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed
+3-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
1-
{{ $link := .Destination -}}
2-
{{ $isRemote := strings.HasPrefix $link "http" -}}
3-
{{ if not $isRemote -}}
4-
{{ $url := urls.Parse .Destination -}}
5-
{{ if $url.Path -}}
6-
{{ $fragment := "" -}}
7-
{{ with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}}
8-
{{ with .Page.GetPage $url.Path }}{{ $link = printf "%s%s" .RelPermalink $fragment }}{{ end -}}
9-
{{ end -}}
10-
{{ end -}}
11-
<a href="{{ $link | safeURL }}"
1+
{{ $isExternal := hasPrefix .Destination "http" -}}
2+
<a href="{{ .Destination | safeURL }}"
123
{{- with .Title}} title="{{ . }}"{{ end -}}
13-
{{- if $isRemote }} target="_blank" rel="noopener"{{ end -}}
4+
{{- if $isExternal }} target="_blank" rel="noopener"{{ end -}}
145
>
156
{{- .Text | safeHTML -}}
167
</a>

0 commit comments

Comments
 (0)