File tree Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ async function fetchData<T>(url: string): Promise<T> {
21
21
"Content-Type" : "application/json" ,
22
22
"User-Agent" : "GraphQL Conf / GraphQL Foundation" ,
23
23
} ,
24
+ cache : "force-cache" ,
24
25
} )
25
26
const data = await response . json ( )
26
27
return data
@@ -58,7 +59,7 @@ async function getSpeakers(): Promise<SchedSpeaker[]> {
58
59
. map ( user => {
59
60
return {
60
61
...user ,
61
- about : stripHtml ( user . about ) . result ,
62
+ about : preprocessDescription ( user . about ) ,
62
63
}
63
64
} )
64
65
. sort ( ( a , b ) => {
Original file line number Diff line number Diff line change
1
+ import React from "react"
2
+
3
+ const URL_REGEX = / h t t p s ? : \/ \/ [ ^ \s ] + / g
4
+
5
+ export function formatDescription ( text : string ) : React . ReactNode {
6
+ const res : React . ReactNode [ ] = [ ]
7
+
8
+ let lastIndex = 0
9
+ let match : RegExpExecArray | null
10
+
11
+ while ( ( match = URL_REGEX . exec ( text ) ) !== null ) {
12
+ if ( match . index > lastIndex ) {
13
+ res . push ( text . slice ( lastIndex , match . index ) )
14
+ }
15
+
16
+ res . push (
17
+ < a
18
+ href = { match [ 0 ] }
19
+ target = "_blank"
20
+ rel = "noopener noreferrer"
21
+ className = "typography-link"
22
+ >
23
+ { match [ 0 ] . replace ( / ^ h t t p s ? : \/ \/ / , "" ) }
24
+ </ a > ,
25
+ )
26
+
27
+ lastIndex = match . index + match [ 0 ] . length
28
+ }
29
+
30
+ if ( lastIndex < text . length ) {
31
+ res . push ( text . slice ( lastIndex ) )
32
+ }
33
+
34
+ return < > { res } </ >
35
+ }
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import { GET_TICKETS_LINK } from "../../links"
21
21
import { CtaCardSection } from "../../components/cta-card-section"
22
22
import { Button } from "@/app/conf/_design-system/button"
23
23
import { SessionTags } from "../../components/session-tags"
24
+ import { formatDescription } from "./format-description"
24
25
25
26
type SessionProps = { params : { id : string } }
26
27
@@ -237,13 +238,13 @@ function Hr({ className }: { className?: string }) {
237
238
}
238
239
239
240
function SessionDescription ( { session } : { session : ScheduleSession } ) {
241
+ const formattedDescription = formatDescription ( session . description || "" )
240
242
241
-
242
243
return (
243
244
< div className = "mt-8 flex gap-4 px-2 pb-8 max-lg:flex-col sm:px-3 lg:mt-16 lg:gap-8 xl:pb-16" >
244
245
< h3 className = "typography-h2 min-w-[320px]" > Session description</ h3 >
245
246
< p className = "typography-body-lg whitespace-pre-wrap" >
246
- { session . description }
247
+ { formattedDescription }
247
248
</ p >
248
249
</ div >
249
250
)
You can’t perform that action at this time.
0 commit comments