add share button to posts for pleb.bz link

This commit is contained in:
plebeius.eth
2023-08-22 14:17:38 +02:00
parent a05e733d30
commit c4361ce78b
10 changed files with 108 additions and 18 deletions
+25
View File
@@ -0,0 +1,25 @@
function handleShareClick(selectedAddress, cid) {
const plebBzBaseURL = "https://pleb.bz/p/";
let shareLink = `${plebBzBaseURL}${selectedAddress}/`;
if (cid === "rules" || cid === "description") {
shareLink += cid;
} else {
shareLink += `c/${cid}`;
}
shareLink += `?redirect=plebchan.eth.limo`;
if (navigator.clipboard) {
navigator.clipboard.writeText(shareLink).then(() => {
console.log("Link copied to clipboard!");
}).catch(err => {
console.error('Could not copy text: ', err);
});
} else {
return;
}
}
export default handleShareClick;