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

Commit

Permalink
fix white space around links
Browse files Browse the repository at this point in the history
Fixes #45

Signed-off-by: Kapunahele Wong <kapunahelewong@gmail.com>
  • Loading branch information
kapunahelewong committed Jul 26, 2021
1 parent 2c48dcc commit 031b447
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{{ $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 -}}
{{- if .Page.GetPage $url.Path }}{{ $link = printf "%s%s" (.Page.GetPage $url.Path).RelPermalink $fragment }}{{ end }}{{ end -}}
{{- end -}}
<a href="{{ $link | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if $isRemote }} target="_blank"{{ end }}>{{- .Text | safeHTML -}}{{ if $isRemote }} <sup><i class="fas fa-external-link-alt"></i></sup>{{ end }}</a>
{{ $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 .Title}} title="{{ . }}"{{ end -}}
{{- if $isRemote }} target="_blank" rel="noopener"{{ end -}}
>
{{- .Text | safeHTML -}}
</a>

0 comments on commit 031b447

Please sign in to comment.