From f9f38101f9d1a75a117560aa543f736d5f3ea4a8 Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Thu, 28 Aug 2025 14:39:09 +0600 Subject: [PATCH] feat: roadmap courses --- src/components/FAQs/FAQs.tsx | 44 +++++++++++++++++++-------- src/pages/[roadmapId]/courses.astro | 46 ++++++++++++++--------------- src/pages/[roadmapId]/index.astro | 4 +-- src/queries/official-roadmap.ts | 24 +++++++++++---- 4 files changed, 76 insertions(+), 42 deletions(-) diff --git a/src/components/FAQs/FAQs.tsx b/src/components/FAQs/FAQs.tsx index 9da9ef96a..b80aae3c9 100644 --- a/src/components/FAQs/FAQs.tsx +++ b/src/components/FAQs/FAQs.tsx @@ -9,6 +9,9 @@ type FAQsProps = { export function FAQs(props: FAQsProps) { const { faqs } = props; + if (faqs.length === 0) { + return null; + } const [activeQuestionIndex, setActiveQuestionIndex] = useState(0); @@ -22,18 +25,35 @@ export function FAQs(props: FAQsProps) {
- {faqs.map((faq, questionIndex) => ( - setActiveQuestionIndex(questionIndex)} - > -
- {guideRenderer.render(faq.description)} -
-
- ))} + {faqs.map((faq, questionIndex) => { + const isTextDescription = + typeof faq?.description === 'string' && + faq?.description?.length > 0; + + return ( + setActiveQuestionIndex(questionIndex)} + > +
+ {!isTextDescription + ? guideRenderer.render(faq.description) + : null} +
+
+ ); + })}
diff --git a/src/pages/[roadmapId]/courses.astro b/src/pages/[roadmapId]/courses.astro index 17b4514a4..028279fdd 100644 --- a/src/pages/[roadmapId]/courses.astro +++ b/src/pages/[roadmapId]/courses.astro @@ -1,19 +1,20 @@ - + diff --git a/src/pages/[roadmapId]/index.astro b/src/pages/[roadmapId]/index.astro index ecf9988b2..40356bbbd 100644 --- a/src/pages/[roadmapId]/index.astro +++ b/src/pages/[roadmapId]/index.astro @@ -83,7 +83,7 @@ if (faqs.length) { } const projects = await getProjectsByRoadmapId(roadmapId); -// const courses = roadmapData.courses || []; +const courses = roadmapData.courses || []; --- diff --git a/src/queries/official-roadmap.ts b/src/queries/official-roadmap.ts index 89a2138c1..867ba3d94 100644 --- a/src/queries/official-roadmap.ts +++ b/src/queries/official-roadmap.ts @@ -19,8 +19,21 @@ export type OfficialRoadmapQuestion = { description: any; }; -export interface OfficialRoadmapDocument { +export type OfficialRoadmapCourse = { _id: string; + title: string; + description: string; + link: string; + instructor: { + name: string; + image: string; + title: string; + }; + features: string[]; +}; + +export interface OfficialRoadmapDocument { + _id?: string; order: number; title: { @@ -30,12 +43,12 @@ export interface OfficialRoadmapDocument { description: string; slug: string; - nodes: Node[]; - edges: Edge[]; + nodes: any[]; + edges: any[]; draft: { - nodes: Node[]; - edges: Edge[]; + nodes: any[]; + edges: any[]; }; seo: { @@ -59,6 +72,7 @@ export interface OfficialRoadmapDocument { questions?: OfficialRoadmapQuestion[]; relatedRoadmaps?: string[]; + courses?: OfficialRoadmapCourse[]; createdAt: Date; updatedAt: Date;