From 9ec652c9c3f4ae2c657f8314759f4c987d99030e Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sat, 20 Dec 2025 19:56:51 -0600 Subject: [PATCH] feat: Add email cloaking functionality and update social links in configuration --- config.toml | 1 + layouts/partials/cloakemail.html | 48 +++++++++++++++++++++++++++++++ layouts/partials/home/social.html | 28 ++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 layouts/partials/cloakemail.html create mode 100644 layouts/partials/home/social.html diff --git a/config.toml b/config.toml index 629b643..8312269 100644 --- a/config.toml +++ b/config.toml @@ -191,6 +191,7 @@ connectsrc = ["'self'", "https://www.google-analytics.com", "https://pagead2.goo name = "Personal email" icon = "fa fa-envelope fa-2x" weight = 3 + email = "eric@ericxliu.me" [[params.social]] name = "RSS" icon = "fa-solid fa-rss fa-2x" diff --git a/layouts/partials/cloakemail.html b/layouts/partials/cloakemail.html new file mode 100644 index 0000000..9f0bb0e --- /dev/null +++ b/layouts/partials/cloakemail.html @@ -0,0 +1,48 @@ +{{/* Get address, protocol and other parameters */}} +{{- $address := .address -}} +{{- $protocol := .protocol | default "mailto" -}} +{{- $class := .class -}} +{{- $displaytext := .display -}} +{{- $parts := split $address "@" -}} +{{- $user := (index $parts 0) -}} +{{- $domain := (index $parts 1) | default "" -}} +{{- $query := .query | default "" -}} +{{/* Compute md5 fingerprint */}} +{{- $fingerprint := md5 (print $address $protocol (index (seq 999 | shuffle) 0)) | truncate 8 "" -}} +{{/* Hide the placeholder span when display text is provided (e.g., icons) */}} +{{- if $displaytext }} + +{{- else }} +{{/* Set via CSS what is displayed when Javascript is disabled. Query is never displayed */}} + +{{- end }} + +{{/* Alter display with Javascript by changing DOM */}} + +{{/* The end */}} \ No newline at end of file diff --git a/layouts/partials/home/social.html b/layouts/partials/home/social.html new file mode 100644 index 0000000..f23f0c5 --- /dev/null +++ b/layouts/partials/home/social.html @@ -0,0 +1,28 @@ +{{ with .Site.Params.social }} + +{{ end }} \ No newline at end of file