瀏覽文檔

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] >}}