hrms-exam/cms/src/routes/+page.server.ts

33 lines
1,013 B
TypeScript
Raw Normal View History

//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';
import type {Exam} from '$lib/data/CMSDataType'
2023-04-07 22:59:53 +07:00
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()
2023-04-07 22:59:53 +07:00
qualify_exams.forEach((e)=>{
e.start? dayjs(e.start).format("DD MMM BBBB"):""
})
}
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"):""
})
}
return { content,image, qualify_exams,competitive_exams };
2023-04-04 12:39:11 +07:00
};