Skip to content

Commit 378066d

Browse files
add share functionality
1 parent 7cfe0fb commit 378066d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/pages/podcasts/index.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,22 @@ export default function Podcasts(): ReactElement {
120120
window.scrollTo({ top: 0, behavior: 'smooth' });
121121
};
122122

123+
const handleShare = async (podcast: PodcastData) => {
124+
if (navigator.share) {
125+
try {
126+
await navigator.share({
127+
title: `Check out this ${podcast.type}`,
128+
url: podcast.spotifyUrl,
129+
});
130+
} catch (err) {
131+
// Fallback to clipboard
132+
navigator.clipboard.writeText(podcast.spotifyUrl);
133+
}
134+
} else {
135+
navigator.clipboard.writeText(podcast.spotifyUrl);
136+
}
137+
};
138+
123139
const handlePodcastClick = (podcast: PodcastData, event: React.MouseEvent | React.KeyboardEvent) => {
124140
const target = event.target as HTMLElement;
125141
if (target.tagName === 'IFRAME' || target.closest('.podcast-embed')) {
@@ -236,7 +252,10 @@ export default function Podcasts(): ReactElement {
236252
<button className="action-btn favorite" title="Add to favorites">
237253
❤️
238254
</button>
239-
<button className="action-btn share" title="Share podcast">
255+
<button className="action-btn share" title="Share podcast" onClick={(e) => {
256+
e.stopPropagation();
257+
handleShare(podcast);
258+
}}>
240259
🔗
241260
</button>
242261
</div>

0 commit comments

Comments
 (0)