Skip to content

Commit

Permalink
Blueskyのシェアボタンを追加する
Browse files Browse the repository at this point in the history
  • Loading branch information
nagutabby committed Feb 16, 2025
1 parent d4f7815 commit 5430b23
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/lib/components/ShareButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import { browser } from "$app/environment";
let isError = $state(false);
let mastodonShareText = $state("");
let blueskyShareText = $state("");
const handleSubmit = (event: SubmitEvent) => {
event.preventDefault();
Expand All @@ -27,7 +29,7 @@
location.pathname + location.search,
);
window.open(
`https://${mastodonInstanceNameField.value}/share?text=${encodeURIComponent(document.title)}${encodeURIComponent("\n")}${encodeURIComponent(location.href)}`,
`https://${mastodonInstanceNameField.value}/share?text=${mastodonShareText}`,
);
}
};
Expand All @@ -39,6 +41,8 @@
let currentUrl = $state("");
onMount(() => {
mastodonShareText = `${encodeURIComponent(document.title)}${encodeURIComponent("\n")}${encodeURIComponent(location.href)}`;
blueskyShareText = `${encodeURIComponent(document.title)}${encodeURIComponent("<br>")}${encodeURIComponent(location.href)}`;
if (browser) {
currentUrl = window.location.href;
}
Expand Down Expand Up @@ -92,7 +96,7 @@
<form id="form" onsubmit={handleSubmit}>
<label
for="mastodon-instance-name"
class={`flex-col input input-bordered flex items-center gap-2 w-full ${isError ? 'input-error' : ''}`}
class={`flex-col input input-bordered flex items-center gap-2 w-full ${isError ? "input-error" : ""}`}
>
<input
type="text"
Expand Down Expand Up @@ -134,6 +138,23 @@
>
</svg>
</a>
<a
role="button"
class="btn"
href="https://bsky.app/intent/compose?text={blueskyShareText}"
aria-label="Bluesky"
target="_blank"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
fill="currentColor"
class="text-secondary"
><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path
d="M111.8 62.2C170.2 105.9 233 194.7 256 242.4c23-47.6 85.8-136.4 144.2-180.2c42.1-31.6 110.3-56 110.3 21.8c0 15.5-8.9 130.5-14.1 149.2C478.2 298 412 314.6 353.1 304.5c102.9 17.5 129.1 75.5 72.5 133.5c-107.4 110.2-154.3-27.6-166.3-62.9l0 0c-1.7-4.9-2.6-7.8-3.3-7.8s-1.6 3-3.3 7.8l0 0c-12 35.3-59 173.1-166.3 62.9c-56.5-58-30.4-116 72.5-133.5C100 314.6 33.8 298 15.7 233.1C10.4 214.4 1.5 99.4 1.5 83.9c0-77.8 68.2-53.4 110.3-21.8z"
/></svg
>
</a>
</div>

<style lang="scss">
Expand Down

0 comments on commit 5430b23

Please sign in to comment.