Skip to content

Commit 0a793aa

Browse files
authored
Refactor ShareButtons component for better readability
1 parent 65d8ba3 commit 0a793aa

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

components/ShareButtons.tsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,31 @@ interface ShareButtonsProps {
55
title?: string;
66
}
77

8-
export default function ShareButtons({ url, title = '' }: ShareButtonsProps) {
9-
const linkedinUrl = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(url)}`;
10-
const twitterUrl = `https://x.com/intent/tweet?url=${encodeURIComponent(url)}` +
8+
export default function ShareButtons({
9+
url,
10+
title = '',
11+
}: ShareButtonsProps) {
12+
const linkedinUrl = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(
13+
url
14+
)}`;
15+
const twitterUrl =
16+
`https://x.com/intent/tweet?url=${encodeURIComponent(url)}` +
1117
(title ? `&text=${encodeURIComponent(title)}` : '');
1218

1319
return (
1420
<div className="flex gap-3">
15-
<a
16-
href={linkedinUrl}
17-
target="_blank"
18-
rel="noopener noreferrer"
21+
<a
22+
href={linkedinUrl}
23+
target="_blank"
24+
rel="noopener noreferrer"
1925
aria-label="Share on LinkedIn (opens in a new tab)"
2026
>
2127
<FaLinkedin size={24} />
2228
</a>
23-
<a
24-
href={twitterUrl}
25-
target="_blank"
26-
rel="noopener noreferrer"
29+
<a
30+
href={twitterUrl}
31+
target="_blank"
32+
rel="noopener noreferrer"
2733
aria-label="Share on X / Twitter (opens in a new tab)"
2834
>
2935
<FaXTwitter size={24} />

0 commit comments

Comments
 (0)