diff --git a/README.md b/README.md index 03a343b..55337af 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ - [ ] Main-Page ( Better design ) - [ ] Markdown and cache ( Better code ) - [ ] Login || LocalStorage and save progress +- [ ] Next and Prev buttons - [ ] Themes, theme settings --- diff --git a/components/CourseCard.tsx b/components/CourseCard.tsx index 70c35d8..00913a2 100644 --- a/components/CourseCard.tsx +++ b/components/CourseCard.tsx @@ -4,16 +4,13 @@ export default function CourseCard(props: { course: Course }) { const { course } = props; return (
-

+

{course.title}

-
- {course.snippet} -
); diff --git a/routes/[...slug].tsx b/routes/[...slug].tsx index 59f19a5..964fbd0 100644 --- a/routes/[...slug].tsx +++ b/routes/[...slug].tsx @@ -1,5 +1,5 @@ import { Course } from "../utils/types.ts"; -import { getCourse } from "../utils/course.ts"; +import { getCourse, getJson } from "../utils/course.ts"; import { Handlers } from "$fresh/server.ts"; import { PageProps } from "$fresh/server.ts"; import { CSS, render } from "$gfm"; @@ -7,21 +7,28 @@ import { Head } from "$fresh/runtime.ts"; import Editor from "../islands/Editor.tsx"; import EditButton from "../components/EditButton.tsx"; -export const handler: Handlers = { - async GET(_req, ctx) { - try { - const course = await getCourse(ctx.params.slug); - if (course === null) return ctx.renderNotFound(); - return ctx.render(course); - } catch { - return ctx.renderNotFound(); - } - }, -}; - -export default function CoursePage(props: PageProps) { - const course = props.data; +export const handler: Handlers<{ course: Course; lable: string | undefined }> = + { + async GET(_req, ctx) { + try { + let lable: string | undefined; + const course = await getCourse(ctx.params.slug); + if (ctx.params.slug.includes("/")) { + lable = await getJson(ctx.params.slug.split("/")[0]); + console.log(lable); + } + if (course === null) return ctx.renderNotFound(); + return ctx.render({ course, lable }); + } catch { + return ctx.renderNotFound(); + } + }, + }; +export default function CoursePage( + props: PageProps<{ course: Course; lable: string | undefined }>, +) { + const { course, lable } = props.data; return ( <> @@ -34,7 +41,6 @@ export default function CoursePage(props: PageProps) { property="og:url" content={`https://nakhlahjs.com/${course.slug}`} /> -