File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,21 @@ import 'react-responsive-carousel/lib/styles/carousel.min.css'
7
7
8
8
export const SpeakersDetails = ( { session } : { session : Session } ) => {
9
9
const [ showChild , setShowChild ] = useState ( false )
10
+
10
11
useEffect ( ( ) => {
11
12
setShowChild ( true )
12
13
} , [ ] )
13
14
14
15
if ( ! showChild ) {
15
16
return null
16
17
}
18
+
19
+ const getTwitterUsername = ( url : string ) : string | null => {
20
+ if ( ! url ) return null
21
+ const match = url . match ( / (?: t w i t t e r \. c o m | x \. c o m ) \/ ( [ ^ / ? # ] + ) / i)
22
+ return match ?. [ 1 ] ?? null
23
+ }
24
+
17
25
return (
18
26
< div className = "w-full flex-wrap lg:w-4/12 flex border-r-0 pr-0 lg:pr-4 mb-6 md:mb-0" >
19
27
< div className = "w-full py-4" >
@@ -62,9 +70,8 @@ export const SpeakersDetails = ({ session }: { session: Session }) => {
62
70
className = "text-primary dark:text-accent text-sm lowercase font-medium"
63
71
>
64
72
@
65
- { speaker . twitter
66
- ? speaker . twitter . split ( 'twitter.com/' ) [ 1 ]
67
- : speaker . name }
73
+ { getTwitterUsername ( speaker . twitter ?? '' ) ||
74
+ speaker . name }
68
75
</ a >
69
76
</ a >
70
77
</ p >
You can’t perform that action at this time.
0 commit comments