From 55f2f22849b213fc1dba56ff911838d806d0bf47 Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Wed, 25 Feb 2026 19:34:25 +0800 Subject: [PATCH 1/3] feat: email obfuscation (#2711) --- assets/js/email.js | 12 +++++++++ layouts/_default/single.html | 15 ++++++++--- layouts/partials/author-extra.html | 10 +++++--- layouts/partials/author-links.html | 8 ++++-- layouts/partials/head.html | 1 + layouts/partials/home/background.html | 9 +++++-- layouts/partials/home/hero.html | 37 ++++++++++++--------------- layouts/partials/sharing-links.html | 9 +++++-- 8 files changed, 67 insertions(+), 34 deletions(-) create mode 100644 assets/js/email.js diff --git a/assets/js/email.js b/assets/js/email.js new file mode 100644 index 00000000..16017543 --- /dev/null +++ b/assets/js/email.js @@ -0,0 +1,12 @@ +(function () { + const links = document.querySelectorAll(".email-link"); + links.forEach((link) => { + const email = atob(link.getAttribute("data-email")); + const subject = link.getAttribute("data-subject"); + let mailto = "mailto:" + email; + if (subject) { + mailto += "?subject=" + encodeURIComponent(subject); + } + link.href = mailto; + }); +})(); diff --git a/layouts/_default/single.html b/layouts/_default/single.html index a6c78f9f..d1c2719d 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -53,11 +53,18 @@ {{ if $replyByEmail }} + class="email-link m-1 rounded bg-neutral-300 p-1.5 text-neutral-700 hover:bg-primary-500 hover:text-neutral dark:bg-neutral-700 dark:text-neutral-300 dark:hover:bg-primary-400 dark:hover:text-neutral-800" + href="#" + data-email="{{ site.Params.Author.email | base64Encode }}" + data-subject="{{ replace (printf "Reply to %s" .Title) "\"" "'" }}"> {{ i18n "article.reply_by_email" | default "Reply by Email" }} + {{ end }} @@ -76,7 +83,7 @@ {{ if .Params.showComments | default (site.Params.article.showComments | default false) }} {{ if templates.Exists "partials/comments.html" }}