11import { defineCollection , reference , z } from "astro:content" ;
2- import { loadData } from "../ utils/dataLoader" ;
2+ import { loadData } from "@ utils/dataLoader" ;
33
44const mode = import . meta. env . MODE ;
55console . log ( `\x1b[35m[EP]\x1b[0m Current MODE: \x1b[1m\x1b[34m${ mode } \x1b[0m` ) ;
@@ -158,18 +158,59 @@ const sessions = defineCollection({
158158 } ) ,
159159} ) ;
160160
161+ //const days = defineCollection({
162+ // type: "data",
163+ // schema: z.object({
164+ // rooms: z.array(z.string()),
165+ // events: z.array(
166+ // z.object({
167+ // rooms: z.array(z.string()),
168+ // event_type: z.string(),
169+ // code: z.string().optional(),
170+ // title: z.string(),
171+ // slug: z.string().optional(),
172+ // session_type: z.string().optional(), // why?
173+ // speakers: z
174+ // .array(
175+ // z.object({
176+ // code: z.string(),
177+ // name: z.string(),
178+ // website_url: z.string(),
179+ // })
180+ // )
181+ // .optional(),
182+ // tweet: z.string().optional().nullable(),
183+ // level: z.string().optional().nullable(),
184+ // start: z.string(),
185+ // website_url: z.string().optional().nullable(),
186+ // duration: z.number(),
187+ // })
188+ // ),
189+ // }),
190+ //});
191+
161192const days = defineCollection ( {
162- type : "data" ,
193+ loader : async ( ) : Promise < any [ ] > => {
194+ const rawSchedule = await loadData ( import . meta. env . EP_SCHEDULE_API ) ;
195+ const schedule = rawSchedule . default ?? rawSchedule ;
196+
197+ return Object . entries ( schedule . days ) . map ( ( [ date , data ] : [ string , any ] ) => ( {
198+ id : date ,
199+ ...data ,
200+ } ) ) ;
201+ } ,
163202 schema : z . object ( {
164- rooms : z . array ( z . string ( ) ) ,
203+ id : z . string ( ) , // the date, like "2024-07-08"
204+ rooms : z . array ( z . string ( ) ) . optional ( ) ,
165205 events : z . array (
166206 z . object ( {
167- rooms : z . array ( z . string ( ) ) ,
168- event_type : z . string ( ) ,
169207 code : z . string ( ) . optional ( ) ,
170- title : z . string ( ) ,
208+ duration : z . number ( ) ,
209+ event_type : z . string ( ) ,
210+ level : z . string ( ) . optional ( ) . nullable ( ) ,
211+ rooms : z . array ( z . string ( ) ) ,
212+ session_type : z . string ( ) . optional ( ) ,
171213 slug : z . string ( ) . optional ( ) ,
172- session_type : z . string ( ) . optional ( ) , // why?
173214 speakers : z
174215 . array (
175216 z . object ( {
@@ -179,11 +220,11 @@ const days = defineCollection({
179220 } )
180221 )
181222 . optional ( ) ,
182- tweet : z . string ( ) . optional ( ) . nullable ( ) ,
183- level : z . string ( ) . optional ( ) . nullable ( ) ,
184223 start : z . string ( ) ,
224+ title : z . string ( ) ,
225+ track : z . string ( ) . optional ( ) . nullable ( ) ,
226+ tweet : z . string ( ) . optional ( ) . nullable ( ) ,
185227 website_url : z . string ( ) . optional ( ) . nullable ( ) ,
186- duration : z . number ( ) ,
187228 } )
188229 ) ,
189230 } ) ,
0 commit comments