2023-04-07 13:49:34 +07:00
|
|
|
//import content from "$lib/data/content/home.html?raw"
|
|
|
|
|
//import { getQualifyExams,getCompetitiveExams } from '$lib/data/info';
|
2023-04-04 12:39:11 +07:00
|
|
|
import type { PageServerLoad } from './$types';
|
2023-04-07 22:59:53 +07:00
|
|
|
import type {Exam} from '$lib/components/Exam'
|
|
|
|
|
import dayjs from 'dayjs'
|
2023-04-07 13:49:34 +07:00
|
|
|
export const load: PageServerLoad = async ({fetch}) => {
|
|
|
|
|
let qualify_exams: Exam[] = []
|
|
|
|
|
let competitive_exams: Exam[] = []
|
|
|
|
|
let content = ""
|
|
|
|
|
let res = await fetch("/api/content?page=home")
|
|
|
|
|
if(res.ok){
|
|
|
|
|
content = (await res.json()).content
|
|
|
|
|
}
|
|
|
|
|
res = await fetch("/api/qualifying")
|
|
|
|
|
if(res.ok){
|
|
|
|
|
qualify_exams = await res.json()
|
2023-04-07 22:59:53 +07:00
|
|
|
qualify_exams.forEach((e)=>{
|
|
|
|
|
e.start? dayjs(e.start).format("DD MMM BBBB"):""
|
|
|
|
|
})
|
2023-04-07 13:49:34 +07:00
|
|
|
}
|
|
|
|
|
res = await fetch("/api/competitive")
|
|
|
|
|
if(res.ok){
|
|
|
|
|
competitive_exams = await res.json()
|
2023-04-07 22:59:53 +07:00
|
|
|
competitive_exams.forEach((e)=>{
|
|
|
|
|
e.start? dayjs(e.start).format("DD MMM BBBB"):""
|
|
|
|
|
})
|
2023-04-07 13:49:34 +07:00
|
|
|
}
|
2023-04-05 17:59:43 +07:00
|
|
|
return { content , qualify_exams,competitive_exams };
|
2023-04-04 12:39:11 +07:00
|
|
|
};
|