🔀 Merge pull request #813 from tomy0000000/dev

🛠 fix: Space in rendered link
pull/805/merge
James Panther 2024-03-09 14:02:23 +11:00 committed by GitHub
commit e2fa33ad46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 4 deletions

View File

@ -1,9 +1,9 @@
{{- $link := .Destination -}} {{- $link := .Destination -}}
{{- $isRemote := strings.HasPrefix $link "http" -}} {{- $isRemote := strings.HasPrefix $link "http" -}}
{{- if not $isRemote }} {{- if not $isRemote }}
{{ $url := urls.Parse .Destination }} {{- $url := urls.Parse .Destination -}}
{{- if $url.Path }} {{- if $url.Path }}
{{ $fragment := "" }} {{- $fragment := "" }}
{{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}} {{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}}
{{- with .Page.GetPage $url.Path }} {{- with .Page.GetPage $url.Path }}
{{ $link = printf "%s%s" .RelPermalink $fragment }} {{ $link = printf "%s%s" .RelPermalink $fragment }}
@ -14,5 +14,4 @@
{{ end -}} {{ end -}}
{{ end -}} {{ end -}}
{{ end -}} {{ end -}}
<!-- prettier-ignore --> <!-- prettier-ignore --><a href="{{ $link | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if $isRemote }} target="_blank" rel="noreferrer"{{ end }}>{{- .Text | safeHTML -}}</a>
<a href="{{ $link | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if $isRemote }} target="_blank" rel="noreferrer"{{ end }}>{{- .Text | safeHTML -}}</a>