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" }}
-
+
{{ partial "comments.html" . }}
diff --git a/layouts/partials/author-extra.html b/layouts/partials/author-extra.html index 0c5eb11b..730c1cf4 100644 --- a/layouts/partials/author-extra.html +++ b/layouts/partials/author-extra.html @@ -21,7 +21,7 @@ height="96" alt="{{ $.Site.Params.Author.name | default " Author" }}" src="{{ $final.RelPermalink }}" - data-zoom-src="{{ $squareImage.RelPermalink }}"> + data-zoom-src="{{ $squareImage.RelPermalink }}" /> {{ end }} {{ end }}
@@ -43,9 +43,13 @@ diff --git a/layouts/partials/sharing-links.html b/layouts/partials/sharing-links.html index 83e63fe9..5bda5cec 100644 --- a/layouts/partials/sharing-links.html +++ b/layouts/partials/sharing-links.html @@ -3,10 +3,15 @@
{{ range . }} {{ with index $links . }} + {{ $isEmail := eq .icon "email" }} {{ partial "icon.html" .icon }} From be7f6b6f8fc93169d2d056e4f9b6eb3128522bb3 Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Wed, 25 Feb 2026 19:36:09 +0800 Subject: [PATCH 2/3] fix: author icon padding --- layouts/partials/author-extra.html | 4 ++-- layouts/partials/author-links.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/layouts/partials/author-extra.html b/layouts/partials/author-extra.html index 730c1cf4..f47ef7fb 100644 --- a/layouts/partials/author-extra.html +++ b/layouts/partials/author-extra.html @@ -40,12 +40,12 @@
{{ . }}
{{ end }}