diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index df7cfd2..30d83f7 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -2,16 +2,18 @@ S'il n'y a pas de / dans l'url d'un lien alors on ajoute le path du répertoire */}} {{ $isExternalLink := strings.HasPrefix .Destination "http" }} -{{ $isNotWebLink := or (not $isExternalLink) (eq 1 (strings.Count .Destination ":")) }} +{{ $isWebLink := or $isExternalLink (eq 0 (.Destination | strings.Count ":")) }} {{ $isTelLink := strings.HasPrefix .Destination "tel:" }} {{ $isMailtoLink := strings.HasPrefix .Destination "mailto:" }} {{ $hasSlash := in .Destination "/" }} -{{ $link := cond (or (or $isExternalLink $isNotWebLink) $hasSlash) .Destination (path.Join "/" .Page.Dir .Destination) }} -{{ if $isNotWebLink }} +{{ if $isWebLink }} + {{ $link := cond (and $isWebLink (and (not $hasSlash) (not $isExternalLink))) (path.Join "/" .Page.Dir .Destination) .Destination }} + {{ .Text | safeHTML }} +{{ else }} {{- $separators := cond $isMailtoLink ":@." ":" -}} {{- $regex := cond $isMailtoLink "[a-z]*:(.*)" "[a-z]*:([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})"}} {{- $replace := cond $isMailtoLink "$1" "$1 $2 $3 $4 $5" -}} - {{- $string := $link -}} + {{- $string := .Destination -}} {{- $params := slice -}} {{- range split $separators "" }} @@ -30,6 +32,4 @@ data-replace="{{ $replace }}" > -{{ else }} - {{ .Text | safeHTML }} {{ end }}