This repository has been archived by the owner on Jun 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #45 Signed-off-by: Kapunahele Wong <kapunahelewong@gmail.com>
- Loading branch information
1 parent
2c48dcc
commit 031b447
Showing
1 changed file
with
16 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |