Hide mail in mailto using JavaScript method

Hide mail in mailto using JavaScript method if page.email contains '@', else use traditional plaint text method
This commit is contained in:
Jorge Arias 2015-09-19 05:11:11 -03:00
parent 015926b7f1
commit 4f7439cf88

View file

@ -6,7 +6,24 @@
{{ page.content | markdownify }}
{% if page.email %}
<p><a href="mailto:{{ page.email }}">{{ page.email }}</a></p>
{% if page.email contains '@' %}
{% assign newemail = page.email | split: '@' %}
<p>
<script>
function join_at_email(user, domain){
return (user && domain)?(user + "@" + domain):"";
}
document.write('<a href="mailto:'
+ join_at_email( "{{ newemail[0] }}", "{{ newemail[1] }}" )
+ '">'
+ join_at_email( "{{ newemail[0] }}", "{{ newemail[1] }}" )
+ '</a>'
);
</script>
</p>
{% else %}
<p><a href="mailto:{{ page.email }}">{{ page.email }}</a></p>
{% endif %}
{% endif %}
{% include social-buttons.html %}