hugo-theme-lowtech/layouts/_default/_markup/render-link.html

17 lines
889 B
HTML

{{/*
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 -}}
{{ $hasSlash := in .Destination "/" }}
{{ $link := cond (and $isWebLink (and (not $hasSlash) (not $isExternalLink))) (path.Join "/" .Page.File.Dir .Destination) .Destination }}
<a href="{{ $link | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if $isExternalLink }} target="_blank" rel="noopener"{{ end }}>{{ .Text | safeHTML }}</a>
{{- else if $isMailtoLink -}}
{{ partial "contact/mail" .Destination }}
{{- else if $isTelLink -}}
{{ partial "contact/telephone" .Destination }}
{{- end -}}