@@ -59,21 +59,23 @@ const keynoters = defineCollection({
5959 } ) ,
6060} ) ;
6161
62- // Shared data fetching function
6362async function getCollectionsData ( ) {
6463 const speakersData = await loadData ( import . meta. env . EP_SPEAKERS_API ) ;
6564 const sessionsData = await loadData ( import . meta. env . EP_SESSIONS_API ) ;
6665
67- // Create indexed versions for efficient lookups
68- const speakersById = Object . entries ( speakersData ) . reduce (
66+ const speakersById = Object . entries (
67+ speakersData as Record < string , { } >
68+ ) . reduce (
6969 ( acc , [ id , speaker ] : [ string , any ] ) => {
7070 acc [ id ] = { id, ...speaker } ;
7171 return acc ;
7272 } ,
7373 { } as Record < string , any >
7474 ) ;
7575
76- const sessionsById = Object . entries ( sessionsData ) . reduce (
76+ const sessionsById = Object . entries (
77+ sessionsData as Record < string , { } >
78+ ) . reduce (
7779 ( acc , [ id , session ] : [ string , any ] ) => {
7880 acc [ id ] = { id, ...session } ;
7981 return acc ;
@@ -93,13 +95,15 @@ const speakers = defineCollection({
9395 loader : async ( ) : Promise < any > => {
9496 const { speakersData, sessionsById } = await getCollectionsData ( ) ;
9597
96- return Object . values ( speakersData ) . map ( ( speaker : any ) => ( {
97- id : speaker . slug ,
98- ...speaker ,
99- submissions : ( speaker . submissions || [ ] )
100- . filter ( ( sessionId : string ) => sessionId in sessionsById )
101- . map ( ( sessionId : string ) => sessionsById [ sessionId ] . slug ) ,
102- } ) ) ;
98+ return Object . values ( speakersData as Record < string , { } > ) . map (
99+ ( speaker : any ) => ( {
100+ id : speaker . slug ,
101+ ...speaker ,
102+ submissions : ( speaker . submissions || [ ] )
103+ . filter ( ( sessionId : string ) => sessionId in sessionsById )
104+ . map ( ( sessionId : string ) => sessionsById [ sessionId ] . slug ) ,
105+ } )
106+ ) ;
103107 } ,
104108 schema : z . object ( {
105109 code : z . string ( ) ,
@@ -122,13 +126,15 @@ const sessions = defineCollection({
122126 loader : async ( ) : Promise < any > => {
123127 const { sessionsData, speakersById } = await getCollectionsData ( ) ;
124128
125- return Object . values ( sessionsData ) . map ( ( session : any ) => ( {
126- id : session . slug ,
127- ...session ,
128- speakers : ( session . speakers || [ ] )
129- . filter ( ( speakerId : string ) => speakerId in speakersById )
130- . map ( ( speakerId : string ) => speakersById [ speakerId ] . slug ) ,
131- } ) ) ;
129+ return Object . values ( sessionsData as Record < string , { } > ) . map (
130+ ( session : any ) => ( {
131+ id : session . slug ,
132+ ...session ,
133+ speakers : ( session . speakers || [ ] )
134+ . filter ( ( speakerId : string ) => speakerId in speakersById )
135+ . map ( ( speakerId : string ) => speakersById [ speakerId ] . slug ) ,
136+ } )
137+ ) ;
132138 } ,
133139 schema : z . object ( {
134140 code : z . string ( ) ,
@@ -159,13 +165,20 @@ const sessions = defineCollection({
159165 } ) ,
160166} ) ;
161167
168+ interface ScheduleData {
169+ days : Record < string , any > ;
170+ }
171+
162172const days = defineCollection ( {
163173 loader : async ( ) : Promise < any [ ] > => {
164- const schedule = await loadData ( import . meta. env . EP_SCHEDULE_API ) ;
174+ const schedule = ( await loadData (
175+ import . meta. env . EP_SCHEDULE_API
176+ ) ) as ScheduleData ;
165177
166- if ( Object . keys ( schedule ) . length === 0 ) {
167- return schedule ;
178+ if ( ! schedule || Object . keys ( schedule ) . length === 0 ) {
179+ return [ ] ;
168180 }
181+
169182 return Object . entries ( schedule . days ) . map ( ( [ date , data ] : [ string , any ] ) => ( {
170183 id : date ,
171184 ...data ,
0 commit comments