35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
//import content from "$lib/data/content/home.html?raw"
|
|
//import { getQualifyExams,getCompetitiveExams } from '$lib/data/info';
|
|
import type { PageServerLoad } from './$types';
|
|
import type {Exam} from '$lib/data/CMSDataType'
|
|
import dayjs from 'dayjs'
|
|
export const load: PageServerLoad = async ({fetch}) => {
|
|
let qualify_exams: Exam[] = []
|
|
let competitive_exams: Exam[] = []
|
|
let content = ""
|
|
let image = undefined
|
|
let res = await fetch("/api/content?page=home")
|
|
if(res.ok){
|
|
const r = await res.json()
|
|
content = r.content
|
|
image = r.image
|
|
}
|
|
res = await fetch("/api/qualifying")
|
|
if(res.ok){
|
|
qualify_exams = await res.json()
|
|
qualify_exams.forEach((e)=>{
|
|
e.date = e.start? dayjs(e.start).format("DD MMM BBBB"):""
|
|
})
|
|
for(let i=qualify_exams.length;i<3;i++){
|
|
qualify_exams.push({id:"0",title:"",date:"",image:""})
|
|
}
|
|
}
|
|
res = await fetch("/api/competitive")
|
|
if(res.ok){
|
|
competitive_exams = await res.json()
|
|
competitive_exams.forEach((e)=>{
|
|
e.date = e.start? dayjs(e.start).format("DD MMM BBBB"):""
|
|
})
|
|
}
|
|
return { content,image, qualify_exams,competitive_exams };
|
|
};
|