import type { PageServerLoad } from './$types' import type {CalendarEvent,Exam} from '$lib/data/CMSDataType' import dayjs from 'dayjs' export const load: PageServerLoad = async ({fetch}) => { let content = "" let exams:Exam[] = [] let res = await fetch("/api/content?page=competitive") if(res.ok){ content = (await res.json()).content } res = await fetch("/api/competitive") if(res.ok){ exams = await res.json() } const events:CalendarEvent[]=[] exams.forEach((e)=>{ if(!e.start){ e.date="" return } e.date= dayjs(e.start).format("DD MMM BBBB") const {id,title,start,category_id} = e let backgroundColor ="rgb(153 153 255 / 34%)" if(category_id) backgroundColor ="#99FFEE" const url = "/competitive/"+id events.push({id,title,start,url,backgroundColor}) }) return {content,exams,events} }