diff --git a/assets/js/email.js b/assets/js/email.js new file mode 100644 index 00000000..4d45f4cf --- /dev/null +++ b/assets/js/email.js @@ -0,0 +1,13 @@ +(function () { + const links = document.querySelectorAll(".email-link"); + links.forEach((link) => { + let email = atob(link.getAttribute("data-email")); + const subject = link.getAttribute("data-subject"); + let mailto = email.startsWith("mailto:") ? email : "mailto:" + email; + + if (subject) { + mailto += (mailto.includes("?") ? "&" : "?") + "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..f47ef7fb 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 }}
@@ -40,12 +40,16 @@
{{ . }}
{{ end }}
-
+
{{ range .data.social }} {{ range $name, $link := . }} + {{ $isEmail := eq $name "email" }} + 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 }}