Change email text to content inner value

master
Will Faught 2 years ago
parent 87c0e4f8e3
commit 437d8721c8

@ -461,19 +461,18 @@ The `paige/email` shortcode hides e-mail addresses from robots.
```
{{< paige/email
address=""
text="" >}}
address="" >}}
{{< /paige/email >}}
```
Inner content: None.
Inner content: Required. String. Markdown. The content.
Parameters:
<dl>
<dt><code>address</code></dt>
<dd>Required. String. The e-mail address.</dd>
<dt><code>text</code></dt>
<dd>Required. String. The anchor text.</dd>
</dl>
### Figure

@ -14,14 +14,14 @@ Paige provides a `paige/email` shortcode that hides e-mail addresses from robots
<!--more-->
## Address and text parameters
## Address and content parameters
Code:
```go-html-template
{{</* paige/email address="example@example.com" text="E-mail me" */>}}
{{</* paige/email address="example@example.com" */>}}E-mail me{{</* /paige/email */>}}
```
Result:
{{< paige/email address="example@example.com" text="E-mail me" >}}
{{< paige/email address="example@example.com" >}}E-mail me{{< /paige/email >}}

@ -1,12 +1,12 @@
{{ $address := .Get "address" }}
{{ $text := .Get "text" }}
{{ $content := .Inner | markdownify }}
{{ if not $address }}
{{ errorf "layouts/shortcodes/paige/email.html: no address" }}
{{ end }}
{{ if not $text }}
{{ errorf "layouts/shortcodes/paige/email.html: no text" }}
{{ if not $content }}
{{ errorf "layouts/shortcodes/paige/email.html: no content" }}
{{ 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>
<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)">{{ $content }}</a>

Loading…
Cancel
Save