feat: Simplify management of emails and phone number

This commit is contained in:
2021-10-21 21:47:42 +02:00
parent 8ca72479d4
commit 1221094d75
5 changed files with 19 additions and 32 deletions

View File

@ -1,9 +1,12 @@
{{- with .Site.Data.contact.mail -}}
{{- $protocol := "mailto" -}}
{{- $mail := . -}}
{{- $mailWithProtocol := print $protocol ":" . -}}
{{- $mailWithProtocol := $mail -}}
{{- if strings.HasPrefix $mail $protocol -}}
{{- $mail = substr $mail 7 -}}
{{- else -}}
{{- $mailWithProtocol = print $protocol ":" $mail -}}
{{- end -}}
<a
class="mail obfuscate"
data-link="{{ range $index := seq (sub (len $mailWithProtocol) 1) 0}}{{ substr $mailWithProtocol $index 1}}{{ end }}"
>{{ range $index := seq (sub (len $mail) 1) 0}}{{ substr $mail $index 1}}{{ end }}</a>
{{- end -}}