From 43e7f0abb93e8c7d0b543091db6c144bc2877077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sun, 22 Mar 2026 21:25:43 -0400 Subject: [PATCH] feat: add email share --- public/language/en-GB/topic.json | 2 ++ public/src/modules/share.js | 12 +++++++++++- src/social.js | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/public/language/en-GB/topic.json b/public/language/en-GB/topic.json index ac69995c89..52808ea5bd 100644 --- a/public/language/en-GB/topic.json +++ b/public/language/en-GB/topic.json @@ -104,6 +104,8 @@ "watch.title": "Be notified of new replies in this topic", "unwatch.title": "Stop watching this topic", "share-this-post": "Share this Post", + "share-mail-subject": "Check out this post on \"%1\"", + "share-mail-body": "I thought you might be interested in this post: %1", "watching": "Watching", "not-watching": "Not Watching", "ignoring": "Ignoring", diff --git a/public/src/modules/share.js b/public/src/modules/share.js index 94478d30cf..db6e4e19ac 100644 --- a/public/src/modules/share.js +++ b/public/src/modules/share.js @@ -1,7 +1,7 @@ 'use strict'; -define('share', ['hooks'], function (hooks) { +define('share', ['hooks', 'translator'], function (hooks, translator) { const share = {}; const baseUrl = window.location.protocol + '//' + window.location.host; @@ -69,6 +69,16 @@ define('share', ['hooks'], function (hooks) { return openShare(mastodon_url, postUrl, 626, 760); }); + addHandler('[component="share/email"]', async function () { + const postUrl = getPostUrl($(this)); + const [subject, body] = await translator.translateKeys([ + translator.compile('topic:share-mail-subject', config.siteTitle), + translator.compile('topic:share-mail-body', postUrl), + ]); + const mailtoUrl = `mailto:?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`; + window.location.href = mailtoUrl; + }); + hooks.fire('action:share.addHandlers', { openShare: openShare }); }; diff --git a/src/social.js b/src/social.js index 9d52114583..c540a391c3 100644 --- a/src/social.js +++ b/src/social.js @@ -45,6 +45,11 @@ social.getPostSharing = async function () { name: 'Mastodon', class: 'fa-brands fa-mastodon', }, + { + id: 'email', + name: 'Email', + class: 'fa-regular fa-envelope', + }, ]; networks = await plugins.hooks.fire('filter:social.posts', networks); networks.forEach((network) => {