Skip to content

Commit

Permalink
Render-link hook: don't rewrite paths (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
chalin authored Aug 23, 2021
1 parent f75a5c9 commit 2a33bf5
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
{{ $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 }}"
{{ $isExternal := hasPrefix .Destination "http" -}}
<a href="{{ .Destination | safeURL }}"
{{- with .Title}} title="{{ . }}"{{ end -}}
{{- if $isRemote }} target="_blank" rel="noopener"{{ end -}}
{{- if $isExternal }} target="_blank" rel="noopener"{{ end -}}
>
{{- .Text | safeHTML -}}
</a>

0 comments on commit 2a33bf5

Please sign in to comment.