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

fix white space around links #93

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>