diff options
| author | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-07 12:47:37 +0900 |
|---|---|---|
| committer | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-07 12:47:37 +0900 |
| commit | 25d33fad4afb795681d428bb52107b509816a95e (patch) | |
| tree | 9d28e5de63e7752a417b5231f43c376e07881485 /src/components | |
| parent | 4694675635a449f6537272ddad2feb2a4724c41d (diff) | |
events: 共有ボタンをX・LINE・コピーに変更
文面を指定できないInstagramとFacebookを外し、文面とURLを渡せる
LINEと、文面をコピーするボタンに置き換えた。コピーはInstagramや
Facebookなどに貼り付けて使える。
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/ScheduleTable.astro | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/src/components/ScheduleTable.astro b/src/components/ScheduleTable.astro index 870cd77..7cbc751 100644 --- a/src/components/ScheduleTable.astro +++ b/src/components/ScheduleTable.astro @@ -61,8 +61,8 @@ const dateHtml = (html: string) => const KINDS: { kind: string; label: string }[] = [ { kind: 'x', label: 'Xでシェア' }, - { kind: 'instagram', label: 'Instagramでシェア' }, - { kind: 'facebook', label: 'Facebookでシェア' }, + { kind: 'line', label: 'LINEで送る' }, + { kind: 'copy', label: '文面をコピー' }, ]; function attachButtons() { @@ -126,35 +126,30 @@ const dateHtml = (html: string) => return; } - if (kind === 'facebook') { - // Facebookのsharerは文面を指定できない(ページのOGPが使われる) + if (kind === 'line') { + // LINEは文面とURLの両方を渡せる window.open( - `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(url)}`, + `https://social-plugins.line.me/lineit/share?text=${encodeURIComponent(text)}&url=${encodeURIComponent(url)}`, '_blank', 'noopener', ); return; } - // Instagramはテキストを渡せる共有URLがないため、端末の共有メニューを使う - const share = (navigator as Navigator & { share?: (data: ShareData) => Promise<void> }) - .share; - if (share) { - try { - await share.call(navigator, { text, url }); - } catch { - // キャンセルされた場合は何もしない - } - return; - } - + // コピー:Instagram・Facebookなど、文面を直接渡せないSNSにも貼れる try { await navigator.clipboard.writeText(`${text}\n${url}`); - window.alert( - 'Instagram はスマートフォンの共有メニューから投稿できます(このブラウザは共有メニューに対応していません)。共有する文面をコピーしました。', - ); + const original = button.title; + button.classList.add('is-done'); + button.title = 'コピーしました'; + button.setAttribute('aria-label', 'コピーしました'); + window.setTimeout(() => { + button.classList.remove('is-done'); + button.title = original; + button.setAttribute('aria-label', original); + }, 1500); } catch { - window.alert('Instagram はスマートフォンの共有メニューから投稿できます。'); + window.alert('このブラウザではコピーできませんでした。文面を選択してコピーしてください。'); } }); |
