Add email shortcode
parent
29abec8f42
commit
36787b9fe7
@ -0,0 +1,23 @@
|
||||
---
|
||||
authors: ["will-faught"]
|
||||
categories: ["paige", "shortcodes"]
|
||||
description: "Demonstration of the Paige email shortcode."
|
||||
tags: ["email"]
|
||||
title: "Email Shortcode"
|
||||
---
|
||||
|
||||
Paige provides a `paige/email` shortcode that hides e-mail addresses from robots.
|
||||
|
||||
<!--more-->
|
||||
|
||||
## Address and text parameters
|
||||
|
||||
Code:
|
||||
|
||||
```go-text-template
|
||||
{{</* paige/email address="example@example.com" text="E-mail me" */>}}
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
{{< paige/email address="example@example.com" text="E-mail me" >}}
|
@ -0,0 +1,12 @@
|
||||
{{ $address := .Get "address" }}
|
||||
{{ $text := .Get "text" }}
|
||||
|
||||
{{ if not $address }}
|
||||
{{ errorf "layouts/shortcodes/paige/email.html: no address" }}
|
||||
{{ end }}
|
||||
|
||||
{{ if not $text }}
|
||||
{{ errorf "layouts/shortcodes/paige/email.html: no text" }}
|
||||
{{ end }}
|
||||
|
||||
<a href="#" data-a="{{ base64Encode (index (split $address `@`) 0) }}" data-b="{{ base64Encode `@` }}" data-c="{{ base64Encode (index (split $address `@`) 1) }}" onclick="this.href = 'mailto:' + atob(this.dataset.a) + atob(this.dataset.b) + atob(this.dataset.c)">{{ $text }}</a>
|
Loading…
Reference in New Issue