Skip to content

Commit 45da714

Browse files
committed
Update logic to get twitter username in SpeakerDetail component #103
1 parent 57b04ed commit 45da714

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

components/sessions/SpeakersDetails.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ export const SpeakersDetails = ({ session }: { session: Session }) => {
1414
if (!showChild) {
1515
return null
1616
}
17+
18+
const getTwitterUsername = (url: string) => {
19+
if (url.includes('twitter.com/')) {
20+
return url.split('twitter.com/')[1]
21+
}
22+
if (url.includes('x.com/')) {
23+
return url.split('x.com/')[1]
24+
}
25+
return null
26+
}
27+
1728
return (
1829
<div className="w-full flex-wrap lg:w-4/12 flex border-r-0 pr-0 lg:pr-4 mb-6 md:mb-0">
1930
<div className="w-full py-4">
@@ -63,7 +74,7 @@ export const SpeakersDetails = ({ session }: { session: Session }) => {
6374
>
6475
@
6576
{speaker.twitter
66-
? speaker.twitter.split('twitter.com/')[1]
77+
? getTwitterUsername(speaker.twitter)
6778
: speaker.name}
6879
</a>
6980
</a>

0 commit comments

Comments
 (0)