feat: add email share

This commit is contained in:
Barış Soner Uşaklı
2026-03-22 21:25:43 -04:00
parent 361134f9a2
commit 43e7f0abb9
3 changed files with 18 additions and 1 deletions

View File

@@ -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",

View File

@@ -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 });
};

View File

@@ -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) => {