1
1
import "server-only"
2
- import { stripHtml } from "string-strip-html"
2
+
3
3
import { SchedSpeaker , ScheduleSession } from "@/app/conf/2023/types"
4
4
5
- import { fetchSchedData } from "../_api/sched-client"
5
+ import { getSpeakers , getSchedule } from "../_api/sched-client"
6
6
import { speakers as speakers2024 } from "../2024/_data"
7
7
import { speakers as speakers2023 } from "../2023/_data"
8
8
@@ -13,64 +13,16 @@ const apiUrl = USE_2025
13
13
: "https://graphqlconf2024.sched.com/api"
14
14
15
15
const token = USE_2025
16
- ? process . env . SCHED_ACCESS_TOKEN_2025
17
- : process . env . SCHED_ACCESS_TOKEN_2024
18
-
19
- async function getSpeakers ( ) : Promise < SchedSpeaker [ ] > {
20
- const users = await fetchSchedData < SchedSpeaker [ ] > (
21
- `${ apiUrl } /user/list?api_key=${ token } &format=json&fields=username,company,position,name,about,location,url,avatar,role,socialurls` ,
22
- )
23
-
24
- const result = users
25
- . filter ( speaker => speaker . role . includes ( "speaker" ) )
26
- . map ( user => {
27
- return {
28
- ...user ,
29
- socialurls : user . socialurls || [ ] ,
30
- about : preprocessDescription ( user . about ) ,
31
- }
32
- } )
33
- . sort ( ( a , b ) => {
34
- if ( a . avatar && ! b . avatar ) return - 1
35
- if ( ! a . avatar && b . avatar ) return 1
36
- return 0
37
- } )
38
-
39
- return result
40
- }
41
-
42
- async function getSchedule ( ) : Promise < ScheduleSession [ ] > {
43
- const sessions = await fetchSchedData < ScheduleSession [ ] > (
44
- `${ apiUrl } /session/export?api_key=${ token } &format=json` ,
45
- )
46
-
47
- const result = sessions . map ( session => {
48
- const { description } = session
49
-
50
- return {
51
- ...session ,
52
- description : preprocessDescription ( description ) ,
53
- }
54
- } )
16
+ ? process . env . SCHED_ACCESS_TOKEN_2025 !
17
+ : process . env . SCHED_ACCESS_TOKEN_2024 !
55
18
56
- return result
19
+ const ctx = {
20
+ apiUrl,
21
+ token,
57
22
}
58
23
59
- function preprocessDescription ( description : string | undefined | null ) : string {
60
- let res = description || ""
61
-
62
- // we respect manual line breaks
63
- res = res . replace ( / < b r \s * \/ ? > / g, "\n" )
64
-
65
- // respecting <li> and <a> tags doesn't make sense, because speakers don't use them consistently
66
- // we'll improve how the descriptions look later down the tree in the session details page
67
- return stripHtml ( res ) . result
68
- }
69
-
70
- export const speakers = await getSpeakers ( )
71
-
72
- // TODO: Collect tags from schedule for speakers.
73
- export const schedule = await getSchedule ( )
24
+ export const speakers = await getSpeakers ( ctx )
25
+ export const schedule = await getSchedule ( ctx )
74
26
75
27
type SpeakerUsername = SchedSpeaker [ "username" ]
76
28
@@ -99,12 +51,3 @@ for (const { username } of speakers2023) {
99
51
returningSpeakers . add ( username )
100
52
}
101
53
}
102
-
103
- const longestSessionName = schedule . reduce ( ( max , session ) => {
104
- if ( session . name . length > max . length ) {
105
- return session . name
106
- }
107
- return max
108
- } , "" )
109
-
110
- console . log ( { longestSessionName } )
0 commit comments