diff options
| author | Xe Iaso <me@christine.website> | 2022-12-06 20:36:42 -0500 |
|---|---|---|
| committer | Xe Iaso <me@christine.website> | 2022-12-06 20:36:42 -0500 |
| commit | 3f0754ab6a7ae0810db3f0f0201a99c194cc5d06 (patch) | |
| tree | 01249b283019b040658073bbfa09f89dfb2dc908 | |
| parent | 29841481992bea1696709da3200c33de7bacdc92 (diff) | |
| download | xesite-3f0754ab6a7ae0810db3f0f0201a99c194cc5d06.tar.xz xesite-3f0754ab6a7ae0810db3f0f0201a99c194cc5d06.zip | |
fix share button
Signed-off-by: Xe Iaso <me@christine.website>
| -rw-r--r-- | src/frontend/mastodon_share_button.tsx | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/frontend/mastodon_share_button.tsx b/src/frontend/mastodon_share_button.tsx index d689abd..f2129e7 100644 --- a/src/frontend/mastodon_share_button.tsx +++ b/src/frontend/mastodon_share_button.tsx @@ -5,6 +5,10 @@ r(() => { let defaultURL = localStorage["mastodon_instance"]; + if (defaultURL == undefined) { + defaultURL = ""; + } + const title = document.querySelectorAll('meta[property="og:title"]')[0] .getAttribute("content"); let series = g("mastodon_share_series").innerText; @@ -26,12 +30,17 @@ ${series}${tags.innerText} @cadey@pony.social`; const tootBox = <textarea rows="6" cols="40">{tootTemplate}</textarea>; const doShare = () => { - const instanceURL = instanceBox.value; + let instanceURL = instanceBox.value; + + if (!instanceURL.startsWith("https://")) { + instanceURL = `https://${instanceURL}`; + } + localStorage["mastodon_instance"] = instanceURL; const text = tootBox.value; - const mastodon_url = u(instanceURL + "/share", { text }); - console.log({ text, mastodon_url }); - window.open(mastodon_url, "_blank"); + const mastodonURL = u(instanceURL + "/share", { text, visibility: "public" }); + console.log({ text, mastodonURL }); + window.open(mastodonURL, "_blank"); }; const shareButton = <button onclick={doShare}>Share</button>; |
