Hugo 编码模块

对文本进行编码以保护电子邮件地址和电话号码不受垃圾邮件机器人的攻击。

Module
github.com/hugomods/encoder
GitHub Stars Used By Used By Used By Used By

短代码

encode 短代码

encode 短代码语法

1{{< encode [text] >}}

encode 短代码参数

text
索引名称类型必填默认值版本
#0textstring--

待编码的文本。

对邮箱地址进行编码
1{{< encode "user@example.org" >}}
[email protected]
对电话号码进行编码
1{{< encode "123-12345678" >}}
123-12345678
1{{< encode-link [protocol] [target] [text] >}}
protocol
索引名称类型必填默认值版本
#0protocolstring--

链接协议,比如 mailtotel

target
索引名称类型必填默认值版本
#1targetstring--

链接目标,如邮箱地址([email protected])、电话号码(123-12345678)。

text
索引名称类型必填默认值版本
#0textstring---

链接文本,默认为 target

*
索引名称类型必填默认值版本
-*string---

其他参数将作为链接属性,比如 classrel

1{{< encode-link "mailto" "user@example.org" >}}
2
3{{< encode-link protocol="mailto" target="[email protected]" text="Send me an email." >}}
4
5{{< encode-link protocol="mailto" target="[email protected]" text="Send me an email." class="text-success" >}}
[email protected] Send me an email. Send me an email.
1{{< encode-link "tel" "123-1234567" >}}
2
3{{< encode-link protocol="tel" target="123-12345678" text="Call me." >}}
4
5{{< encode-link protocol="tel" target="123-12345678" text="Call me." class="text-success" >}}
123-1234567 Call me. Call me.

encode-email 短代码

encode-link 邮箱链接短代码的快捷方式,其无需指定 protocol 参数。

1{{< encode-email [target] [text] >}}

encode-tel 短代码

encode-link 电话号码短代码的快捷方式,其无需指定 protocol 参数。

1{{< encode-tel [target] [text] >}}