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 {{< paige/email
address="" address="" >}}
text="" >}}
{{< /paige/email >}}
``` ```
Inner content: None. Inner content: Required. String. Markdown. The content.
Parameters: Parameters:
<dl> <dl>
<dt><code>address</code></dt> <dt><code>address</code></dt>
<dd>Required. String. The e-mail address.</dd> <dd>Required. String. The e-mail address.</dd>
<dt><code>text</code></dt>
<dd>Required. String. The anchor text.</dd>
</dl> </dl>
### Figure ### Figure

@ -14,14 +14,14 @@ Paige provides a `paige/email` shortcode that hides e-mail addresses from robots
<!--more--> <!--more-->
## Address and text parameters ## Address and content parameters
Code: Code:
```go-html-template ```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: 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" }} {{ $address := .Get "address" }}
{{ $text := .Get "text" }} {{ $content := .Inner | markdownify }}
{{ if not $address }} {{ if not $address }}
{{ errorf "layouts/shortcodes/paige/email.html: no address" }} {{ errorf "layouts/shortcodes/paige/email.html: no address" }}
{{ end }} {{ end }}
{{ if not $text }} {{ if not $content }}
{{ errorf "layouts/shortcodes/paige/email.html: no text" }} {{ errorf "layouts/shortcodes/paige/email.html: no content" }}
{{ end }} {{ 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