2024-10-05 15:04:17 +08:00
|
|
|
import React from 'react'
|
|
|
|
import ResponsiveNav from "@/components/Navbar/ResponsiveNav";
|
|
|
|
import { fetchCourses, fetchCourse, fetchSettings } from "@/utils";
|
|
|
|
import dynamic from 'next/dynamic'
|
2024-10-08 19:08:37 +08:00
|
|
|
|
2024-10-05 15:04:17 +08:00
|
|
|
const DynamicComponent = dynamic(() => import('@/components/Course/Course'), {
|
|
|
|
ssr: false,
|
|
|
|
})
|
|
|
|
async function getCourses() {
|
|
|
|
const courses = await fetchCourses();
|
|
|
|
return courses;
|
|
|
|
}
|
2024-10-08 15:11:16 +08:00
|
|
|
// async function getCourse(slug: string) {
|
|
|
|
// const course = await fetchCourse(slug);
|
|
|
|
// return course;
|
|
|
|
// }
|
2024-10-05 15:04:17 +08:00
|
|
|
|
|
|
|
async function getSettings() {
|
|
|
|
const settings = await fetchSettings();
|
|
|
|
return settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default async function Page({ params }: { params: { slug: string } }) {
|
|
|
|
const courses = await getCourses();
|
|
|
|
const settings = await getSettings();
|
|
|
|
//const course = await getCourse(params.slug);
|
|
|
|
const course = courses.find(course => course.id === params.slug);
|
|
|
|
if (!course) {
|
|
|
|
throw new Error(`Course with slug ${params.slug} not found`);
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div className='bg-[#F6E8E8]'>
|
2024-10-08 19:08:37 +08:00
|
|
|
|
2024-10-05 15:04:17 +08:00
|
|
|
<ResponsiveNav courses={courses} settings={settings} />
|
2024-10-06 11:52:45 +08:00
|
|
|
<DynamicComponent course={course} settings={settings} />
|
2024-10-05 15:04:17 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|