-
Notifications
You must be signed in to change notification settings - Fork 1
/
CourseCardCore.tsx
34 lines (31 loc) · 932 Bytes
/
CourseCardCore.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { headers } from "next/headers";
import { CourseListType } from "../types/CourseListType";
import CardList from "./CardList";
import { config } from "@/lib/config";
async function getAllCoursesDate(host: string) {
const res = await fetch(`${config.apiPrefix}${host}/api/plan`, {
cache: "no-store", //ssr
});
const data = await res.json();
return data.posts;
}
const CourseCardCore = async () => {
const host = headers().get("host");
const AllCourseDate = await getAllCoursesDate(host!);
return (
<>
<div className="mt-4 grid gap-5 grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
{AllCourseDate.map((course: CourseListType) => (
<CardList
key={course.id}
id={course.id}
tittle={course.title}
content={course.content}
user={course.user}
/>
))}
</div>
</>
);
};
export default CourseCardCore;