Skip to content

Commit 1c41880

Browse files
committed
Improve Mastodon sharing functionality and update input handling
1 parent a22fa5d commit 1c41880

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/layouts/BlogPost.astro

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const platforms = [
5555
id="mastodon-input"
5656
placeholder="mastodon.social"
5757
type="text"
58-
value={url}
5958
data-encoded-text={encodedText}
6059
data-encoded-url={encodedUrl}
6160
/>
@@ -131,6 +130,15 @@ const platforms = [
131130
) as HTMLDialogElement;
132131
element?.addEventListener("click", () => {
133132
navigator.clipboard.writeText(element.dataset.url ?? window.location.href);
133+
const icon = element.querySelector("span");
134+
if (icon) {
135+
icon.classList.remove("ph-link");
136+
icon.classList.add("ph-check");
137+
setTimeout(() => {
138+
icon.classList.remove("ph-check");
139+
icon.classList.add("ph-link");
140+
}, 1000);
141+
}
134142
});
135143
document.getElementById("mastodon-btn")?.addEventListener("click", () => {
136144
mastodonDialog.showModal();
@@ -139,6 +147,7 @@ const platforms = [
139147

140148
function submitMastodon() {
141149
const input = mastodonInput.value;
150+
if (!input) return;
142151
const { encodedText, encodedUrl } = mastodonInput.dataset;
143152
const link = `https://${input}/share?text=${encodedText}&url=${encodedUrl}`;
144153
window.open(link, "_blank");

0 commit comments

Comments
 (0)