2021-03-13 00:17:54 +01:00
|
|
|
{{/*
|
|
|
|
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" }}
|
|
|
|
{{ $isWebLink := or $isExternalLink (eq 0 (.Destination | strings.Count ":")) }}
|
|
|
|
{{ $isTelLink := strings.HasPrefix .Destination "tel:" }}
|
|
|
|
{{ $isMailtoLink := strings.HasPrefix .Destination "mailto:" }}
|
|
|
|
{{- if $isWebLink -}}
|
2021-10-21 21:47:42 +02:00
|
|
|
{{ $hasSlash := in .Destination "/" }}
|
2021-05-12 08:41:33 +02:00
|
|
|
{{ $link := cond (and $isWebLink (and (not $hasSlash) (not $isExternalLink))) (path.Join "/" .Page.File.Dir .Destination) .Destination }}
|
2021-03-13 00:17:54 +01:00
|
|
|
<a href="{{ $link | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if $isExternalLink }} target="_blank" rel="noopener"{{ end }}>{{ .Text | safeHTML }}</a>
|
2021-10-21 21:47:42 +02:00
|
|
|
{{- else if $isMailtoLink -}}
|
|
|
|
{{ partial "contact/mail" .Destination }}
|
|
|
|
{{- else if $isTelLink -}}
|
|
|
|
{{ partial "contact/telephone" .Destination }}
|
2021-03-13 00:17:54 +01:00
|
|
|
{{- end -}}
|