feat: Simplify management of emails and phone number
This commit is contained in:
@ -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 -}}
|
||||
|
@ -1,9 +1,12 @@
|
||||
{{- with .Site.Data.contact.telephone -}}
|
||||
{{- $protocol := "tel" -}}
|
||||
{{- $tel := . -}}
|
||||
{{- $telWithProtocol := print $protocol ":" (replace $tel " " "") -}}
|
||||
{{- $telWithProtocol := $tel -}}
|
||||
{{- if strings.HasPrefix $tel $protocol -}}
|
||||
{{- $tel = substr $tel 4 -}}
|
||||
{{- else -}}
|
||||
{{- $telWithProtocol := print $protocol ":" (replace $tel " " "") -}}
|
||||
{{- end -}}
|
||||
<a
|
||||
class="tel obfuscate"
|
||||
data-link="{{ range $index := seq (sub (len $telWithProtocol) 1) 0}}{{ substr $telWithProtocol $index 1}}{{ end }}"
|
||||
>{{ range $index := seq (sub (len $tel) 1) 0}}{{ substr $tel $index 1}}{{ end }}</a>
|
||||
{{- end -}}
|
||||
|
Reference in New Issue
Block a user