Add email shortcode
This commit is contained in:
23
README.md
23
README.md
@@ -29,7 +29,7 @@ It's a versatile canvas that serves most web needs.
|
|||||||
- Comments
|
- Comments
|
||||||
- Customizable
|
- Customizable
|
||||||
- Dark color scheme
|
- Dark color scheme
|
||||||
- E-mail protection
|
- Email shortcode
|
||||||
- Facebook sharing
|
- Facebook sharing
|
||||||
- Figure shortcode
|
- Figure shortcode
|
||||||
- Gallery shortcode
|
- Gallery shortcode
|
||||||
@@ -384,6 +384,27 @@ Parameters:
|
|||||||
<dd>Optional. String. Hugo <a href="https://gohugo.io/content-management/syntax-highlighting/#highlight-shortcode">highlight options</a>.</dd>
|
<dd>Optional. String. Hugo <a href="https://gohugo.io/content-management/syntax-highlighting/#highlight-shortcode">highlight options</a>.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
### Email
|
||||||
|
|
||||||
|
The `paige/email` shortcode hides e-mail addresses from robots.
|
||||||
|
|
||||||
|
```
|
||||||
|
{{< paige/email
|
||||||
|
address=""
|
||||||
|
text="" >}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Inner content: None.
|
||||||
|
|
||||||
|
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
|
### Figure
|
||||||
|
|
||||||
The `paige/figure` shortcode provides a figure.
|
The `paige/figure` shortcode provides a figure.
|
||||||
|
23
exampleSite/content/shortcodes/email.md
Normal file
23
exampleSite/content/shortcodes/email.md
Normal file
@@ -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" >}}
|
12
layouts/shortcodes/paige/email.html
Normal file
12
layouts/shortcodes/paige/email.html
Normal file
@@ -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>
|
Reference in New Issue
Block a user