From 33f4e3451627bb2c65cce70adfc6c686e138a123 Mon Sep 17 00:00:00 2001 From: Vedant Bidari Date: Tue, 2 Jun 2026 01:20:34 +0530 Subject: [PATCH] fix: await params across all dynamic routes for next 15 compatibility --- app/bookmarks/page.tsx | 110 +++--- app/flashcards/[slug]/page.tsx | 31 ++ app/flashcards/page.tsx | 87 +++++ app/page.tsx | 56 ++-- app/quiz/[slug]/page.tsx | 52 +-- app/quiz/page.tsx | 150 ++++----- app/sem1/c/[chapter]/page.tsx | 276 ++++++++-------- app/sem1/c/page.tsx | 10 +- app/sem1/ec/[chapter]/page.tsx | 186 +++++------ app/sem1/ec/page.tsx | 20 +- app/sem1/em1/[chapter]/page.tsx | 259 +++++++-------- app/sem1/em1/page.tsx | 10 +- app/sem1/ep/[chapter]/page.tsx | 271 +++++++-------- app/sem1/ep/page.tsx | 10 +- app/sem2/dsc/[chapter]/page.tsx | 265 +++++++-------- app/sem2/dsc/page.tsx | 10 +- app/sem2/em2/[chapter]/page.tsx | 265 +++++++-------- app/sem2/em2/page.tsx | 10 +- app/sem2/oops/[chapter]/page.tsx | 291 ++++++++-------- app/sem2/oops/page.tsx | 10 +- app/sem3/coa/[chapter]/page.tsx | 235 ++++++------- app/sem3/coa/page.tsx | 10 +- app/sem4/dbms/[chapter]/page.tsx | 235 ++++++------- app/sem4/dbms/page.tsx | 10 +- app/sem4/dops/[chapter]/page.tsx | 251 +++++++------- app/sem4/dops/page.tsx | 10 +- app/sem4/os/[chapter]/page.tsx | 417 +++++++++++------------ app/sem4/os/page.tsx | 10 +- app/sem5/cd/[chapter]/page.tsx | 524 ++++++++++++++--------------- app/sem5/cle/[chapter]/page.tsx | 376 ++++++++++----------- app/sem6/ml/[chapter]/page.tsx | 552 +++++++++++++++---------------- 31 files changed, 2568 insertions(+), 2441 deletions(-) create mode 100644 app/flashcards/[slug]/page.tsx create mode 100644 app/flashcards/page.tsx diff --git a/app/bookmarks/page.tsx b/app/bookmarks/page.tsx index a1a447d..9b504b6 100644 --- a/app/bookmarks/page.tsx +++ b/app/bookmarks/page.tsx @@ -1,56 +1,56 @@ -"use client"; -import { useBookmarks } from "../hooks/useBookmarks"; -import Navbar from "@/app/components/navbar"; -import Link from "next/link"; -import { useEffect, useState } from "react"; -import { Road_Rage } from "next/font/google"; - -const roadRage = Road_Rage({ - variable: "--font-road-rage", - subsets: ["latin"], - weight: "400", -}); - -export default function BookmarksPage() { - const { bookmarks, toggleBookmark } = useBookmarks(); - const [mounted, setMounted] = useState(false); - - useEffect(() => setMounted(true), []); - if (!mounted) return null; - - return ( -
- - - - Back to Home - -

My Bookmarks

- {bookmarks.length === 0 ? ( -

- No bookmarks saved yet. Go explore some subjects! -

- ) : ( -
    - {bookmarks.map((b) => ( -
  • - - {b.title} - - -
  • - ))} -
- )} -
- ); +"use client"; +import { useBookmarks } from "../hooks/useBookmarks"; +import Navbar from "@/app/components/navbar"; +import Link from "next/link"; +import { useEffect, useState } from "react"; +import { Road_Rage } from "next/font/google"; + +const roadRage = Road_Rage({ + variable: "--font-road-rage", + subsets: ["latin"], + weight: "400", +}); + +export default function BookmarksPage() { + const { bookmarks, toggleBookmark } = useBookmarks(); + const [mounted, setMounted] = useState(false); + + useEffect(() => setMounted(true), []); + if (!mounted) return null; + + return ( +
+ + + + Back to Home + +

My Bookmarks

+ {bookmarks.length === 0 ? ( +

+ No bookmarks saved yet. Go explore some subjects! +

+ ) : ( +
    + {bookmarks.map((b) => ( +
  • + + {b.title} + + +
  • + ))} +
+ )} +
+ ); } \ No newline at end of file diff --git a/app/flashcards/[slug]/page.tsx b/app/flashcards/[slug]/page.tsx new file mode 100644 index 0000000..2ed6425 --- /dev/null +++ b/app/flashcards/[slug]/page.tsx @@ -0,0 +1,31 @@ +import { flashcardDecks } from "@/lib/flashcardData"; +import { notFound } from "next/navigation"; +import FlashcardClient from "./FlashcardClient"; +import { Metadata } from "next"; + +export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise { + const { slug } = await params; + const deck = flashcardDecks.find((d) => d.slug === slug); + if (!deck) return {}; + + return { + title: `${deck.subject} Flashcards - openCSE`, + description: deck.description, + }; +} + +export function generateStaticParams() { + return flashcardDecks.map((deck) => ({ + slug: deck.slug, + })); +} + +export default function FlashcardDeckPage({ params }: { params: { slug: string } }) { + const deck = flashcardDecks.find((d) => d.slug === slug); + + if (!deck) { + notFound(); + } + + return ; +} diff --git a/app/flashcards/page.tsx b/app/flashcards/page.tsx new file mode 100644 index 0000000..286e58a --- /dev/null +++ b/app/flashcards/page.tsx @@ -0,0 +1,87 @@ +"use client"; + +import Link from "next/link"; +import Navbar from "@/app/components/navbar"; +import { flashcardDecks } from "@/lib/flashcardData"; +import { Road_Rage } from "next/font/google"; + +const roadRage = Road_Rage({ + variable: "--font-road-rage", + subsets: ["latin"], + weight: "400", +}); + +export default function FlashcardsIndex() { + return ( +
+ + +
+
+ +
+

+ Smart Flashcards +

+

+ Master core engineering concepts with an algorithmic Spaced Repetition System. +

+
+
+ +
+

+ Select a Subject +

+ +
+ {flashcardDecks.map((deck) => ( +
+

+ {deck.subject} +

+

{deck.description}

+ +
+ + {deck.cards.length} Core Concepts + + + Review + +
+
+ ))} +
+
+
+ ); +} diff --git a/app/page.tsx b/app/page.tsx index f8a441e..6fbc514 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,28 +1,28 @@ -import ContributionsSection from "./components/contribute"; -import HeroSection from "./components/hero"; -import Navbar from "./components/navbar"; -import SponsorSection from "./components/sponsor"; -import SubjectsSection from "./components/subjects"; -import RequestCourse from "./components/request-course"; -export default function Home() { - return ( -
- - -
- - -
- -
- - -
- ); -} +import ContributionsSection from "./components/contribute"; +import HeroSection from "./components/hero"; +import Navbar from "./components/navbar"; +import SponsorSection from "./components/sponsor"; +import SubjectsSection from "./components/subjects"; +import RequestCourse from "./components/request-course"; +export default function Home() { + return ( +
+ + +
+ + +
+ +
+ + +
+ ); +} diff --git a/app/quiz/[slug]/page.tsx b/app/quiz/[slug]/page.tsx index c4d9bff..8b7d973 100644 --- a/app/quiz/[slug]/page.tsx +++ b/app/quiz/[slug]/page.tsx @@ -1,27 +1,27 @@ -// app/quiz/[slug]/page.tsx -import { getQuizBySlug, moduleQuizzes, quizzes } from "@/lib/quizData"; -import { notFound } from "next/navigation"; -import QuizClient from "./QuizClient"; - -// Pre-generate all quiz pages at build time -export function generateStaticParams() { - return [...quizzes, ...moduleQuizzes].map((q) => ({ slug: q.slug })); -} - -export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }) { - const { slug } = await params; - const quiz = getQuizBySlug(slug); - if (!quiz) return {}; - return { - title: `${quiz.subject} Quiz | openCSE`, - description: quiz.description, - }; -} - -export default async function QuizPage({ params }: { params: Promise<{ slug: string }> }) { - const { slug } = await params; - const quiz = getQuizBySlug(slug); - if (!quiz) notFound(); - - return ; +// app/quiz/[slug]/page.tsx +import { getQuizBySlug, moduleQuizzes, quizzes } from "@/lib/quizData"; +import { notFound } from "next/navigation"; +import QuizClient from "./QuizClient"; + +// Pre-generate all quiz pages at build time +export function generateStaticParams() { + return [...quizzes, ...moduleQuizzes].map((q) => ({ slug: q.slug })); +} + +export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }) { + const { slug } = await params; + const quiz = getQuizBySlug(slug); + if (!quiz) return {}; + return { + title: `${quiz.subject} Quiz | openCSE`, + description: quiz.description, + }; +} + +export default async function QuizPage({ params }: { params: Promise<{ slug: string }> }) { + const { slug } = await params; + const quiz = getQuizBySlug(slug); + if (!quiz) notFound(); + + return ; } \ No newline at end of file diff --git a/app/quiz/page.tsx b/app/quiz/page.tsx index 4f5fe2a..6ad5415 100644 --- a/app/quiz/page.tsx +++ b/app/quiz/page.tsx @@ -1,76 +1,76 @@ -// app/quiz/page.tsx -import Link from "next/link"; -import Navbar from "@/app/components/navbar"; -import { quizzes } from "@/lib/quizData"; -import { Road_Rage } from "next/font/google"; - -const roadRage = Road_Rage({ - variable: "--font-road-rage", - subsets: ["latin"], - weight: "400", -}); - -export const metadata = { - title: "Quizzes | openCSE", - description: "Test your CSE knowledge with subject-wise quizzes.", -}; - -export default function QuizIndexPage() { - return ( -
- - -
-
- -
-

- CSE Quizzes -

-

- All Subjects -

-
-
- -
-
-

- Test yourself with 10-question quizzes for each subject. Instant feedback, no time limit. -

-
- -
- {quizzes.map((quiz) => ( - - {quiz.subject} - - {quiz.questions.length} qs - - - ))} -
-
-
- ); +// app/quiz/page.tsx +import Link from "next/link"; +import Navbar from "@/app/components/navbar"; +import { quizzes } from "@/lib/quizData"; +import { Road_Rage } from "next/font/google"; + +const roadRage = Road_Rage({ + variable: "--font-road-rage", + subsets: ["latin"], + weight: "400", +}); + +export const metadata = { + title: "Quizzes | openCSE", + description: "Test your CSE knowledge with subject-wise quizzes.", +}; + +export default function QuizIndexPage() { + return ( +
+ + +
+
+ +
+

+ CSE Quizzes +

+

+ All Subjects +

+
+
+ +
+
+

+ Test yourself with 10-question quizzes for each subject. Instant feedback, no time limit. +

+
+ +
+ {quizzes.map((quiz) => ( + + {quiz.subject} + + {quiz.questions.length} qs + + + ))} +
+
+
+ ); } \ No newline at end of file diff --git a/app/sem1/c/[chapter]/page.tsx b/app/sem1/c/[chapter]/page.tsx index 38e865e..8725fff 100644 --- a/app/sem1/c/[chapter]/page.tsx +++ b/app/sem1/c/[chapter]/page.tsx @@ -1,138 +1,138 @@ -import Link from "next/link"; -import { Ch0Content } from "../content/chapter0"; -import { Ch1Content } from "../content/chapter1"; -import { Ch2Content } from "../content/chapter2"; -import { Ch3Content } from "../content/chapter3"; -import { Ch4Content } from "../content/chapter4"; -import { Ch5Content } from "../content/chapter5"; -import { Ch6Content } from "../content/chapter6"; -import { moduleQuizzes } from "@/lib/quizData"; -import ChapterQuizInline from "../components/ChapterQuizInline"; -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; -import { Righteous } from "next/font/google"; -import BookmarkButton from "../../../components/BookmarkButton"; -const righteous = Righteous({ - subsets: ['latin'], - weight: '400', - variable: '--font-righteous', - }); - -// Chapter data -const chapters = [ - { id: "ch0", title: "Course Outline", component: Ch0Content }, - { id: "ch1", title: "Introduction to Computing", component: Ch1Content }, - { id: "ch2", title: "Overview of C", component: Ch2Content }, - { id: "ch3", title: "Data Types, I/O, Decision Making and Loops", component: Ch3Content }, - { id: "ch4", title: "Arrays, Strings, and Functions", component: Ch4Content }, - { id: "ch5", title: "Pointers, Structures, and Unions", component: Ch5Content }, - { id: "ch6", title: "File Management, Dynamic Memory, and Preprocessors", component: Ch6Content }, -]; - -type ChapterProps = { - params: Promise<{ chapter: string }>; -}; - -export default async function ChapterPage({ params }: ChapterProps) { - const { chapter: chapterId } = await params; - const currentIndex = chapters.findIndex((c) => c.id === chapterId); - const chapter = chapters[currentIndex]; - - if (!chapter) { - return

Chapter not found

; - } - - const ChapterComponent = chapter.component; - const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; - const nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; - - const chapterQuizSlugMap: Record = { - ch1: "c-intro", - ch2: "c-overview", - ch3: "c-data-types", - ch4: "c-arrays-functions", - ch5: "c-pointers-structures", - ch6: "c-file-memory-preprocessors", - }; - - const chapterQuiz = moduleQuizzes.find(async (quiz) => quiz.slug === chapterQuizSlugMap[(await params).chapter]); - - return ( -
- {/* Content */} -
-

- Programming in C -

-
-

- {chapter.title} -

- -
- - {/* Navigation Buttons */} -
- {prevChapter ? ( - - Previous - - ) : ( -
- )} - - {nextChapter ? ( - - Next - - ) : ( -
- )} -
- -
- - - {chapterQuiz ? ( -
- -
- ) : null} -
- - {/* Navigation Buttons */} -
- {prevChapter ? ( - - {prevChapter.title} - - ) : ( -
- )} - - {nextChapter ? ( - - {nextChapter.title} - - ) : ( -
- )} -
-
- ); -} +import Link from "next/link"; +import { Ch0Content } from "../content/chapter0"; +import { Ch1Content } from "../content/chapter1"; +import { Ch2Content } from "../content/chapter2"; +import { Ch3Content } from "../content/chapter3"; +import { Ch4Content } from "../content/chapter4"; +import { Ch5Content } from "../content/chapter5"; +import { Ch6Content } from "../content/chapter6"; +import { moduleQuizzes } from "@/lib/quizData"; +import ChapterQuizInline from "../components/ChapterQuizInline"; +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { Righteous } from "next/font/google"; +import BookmarkButton from "../../../components/BookmarkButton"; +const righteous = Righteous({ + subsets: ['latin'], + weight: '400', + variable: '--font-righteous', + }); + +// Chapter data +const chapters = [ + { id: "ch0", title: "Course Outline", component: Ch0Content }, + { id: "ch1", title: "Introduction to Computing", component: Ch1Content }, + { id: "ch2", title: "Overview of C", component: Ch2Content }, + { id: "ch3", title: "Data Types, I/O, Decision Making and Loops", component: Ch3Content }, + { id: "ch4", title: "Arrays, Strings, and Functions", component: Ch4Content }, + { id: "ch5", title: "Pointers, Structures, and Unions", component: Ch5Content }, + { id: "ch6", title: "File Management, Dynamic Memory, and Preprocessors", component: Ch6Content }, +]; + +type ChapterProps = { + params: Promise<{ chapter: string }>; +}; + +export default async function ChapterPage({ params }: ChapterProps) { + const { chapter: chapterId } = await params; + const currentIndex = chapters.findIndex((c) => c.id === chapterId); + const chapter = chapters[currentIndex]; + + if (!chapter) { + return

Chapter not found

; + } + + const ChapterComponent = chapter.component; + const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; + const nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + + const chapterQuizSlugMap: Record = { + ch1: "c-intro", + ch2: "c-overview", + ch3: "c-data-types", + ch4: "c-arrays-functions", + ch5: "c-pointers-structures", + ch6: "c-file-memory-preprocessors", + }; + + const chapterQuiz = moduleQuizzes.find(async (quiz) => quiz.slug === chapterQuizSlugMap[(await params).chapter]); + + return ( +
+ {/* Content */} +
+

+ Programming in C +

+
+

+ {chapter.title} +

+ +
+ + {/* Navigation Buttons */} +
+ {prevChapter ? ( + + Previous + + ) : ( +
+ )} + + {nextChapter ? ( + + Next + + ) : ( +
+ )} +
+ +
+ + + {chapterQuiz ? ( +
+ +
+ ) : null} +
+ + {/* Navigation Buttons */} +
+ {prevChapter ? ( + + {prevChapter.title} + + ) : ( +
+ )} + + {nextChapter ? ( + + {nextChapter.title} + + ) : ( +
+ )} +
+
+ ); +} diff --git a/app/sem1/c/page.tsx b/app/sem1/c/page.tsx index dc3a8f8..981bc58 100644 --- a/app/sem1/c/page.tsx +++ b/app/sem1/c/page.tsx @@ -1,5 +1,5 @@ -import { redirect } from "next/navigation"; - -export default function Page() { - redirect("/sem1/c/ch0"); -} +import { redirect } from "next/navigation"; + +export default function Page() { + redirect("/sem1/c/ch0"); +} diff --git a/app/sem1/ec/[chapter]/page.tsx b/app/sem1/ec/[chapter]/page.tsx index 78b8c0a..6b4fe91 100644 --- a/app/sem1/ec/[chapter]/page.tsx +++ b/app/sem1/ec/[chapter]/page.tsx @@ -1,94 +1,94 @@ -import Link from "next/link"; -import { Ch0Content } from "../content/chapter0"; -import { Ch1Content } from "../content/chapter1"; -import { Ch2Content } from "../content/chapter2"; -import { Ch3Content } from "../content/chapter3"; -import { Ch4Content } from "../content/chapter4"; -import { Ch5Content } from "../content/chapter5"; -import { Ch6Content } from "../content/chapter6"; -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; -import { Righteous } from "next/font/google"; - -const righteous = Righteous({ - subsets: ["latin"], - weight: "400", - variable: "--font-righteous", -}); - -const chapters = [ - { id: "ch0", title: "Course Outline", component: Ch0Content }, - { id: "ch1", title: "Basics of Communication", component: Ch1Content }, - { id: "ch2", title: "Written Communication", component: Ch2Content }, - { id: "ch3", title: "Verbal & Non-Verbal Communication", component: Ch3Content }, - { id: "ch4", title: "Reading Comprehension", component: Ch4Content }, - { id: "ch5", title: "Grammar Essentials", component: Ch5Content }, - { id: "ch6", title: "Presentation & Interview Skills", component: Ch6Content }, -]; - -type ChapterProps = { - params: Promise<{ chapter: string }>; -}; - -export default async function ChapterPage({ params }: ChapterProps) { - const { chapter: chapterId } = await params; - - const currentIndex = chapters.findIndex((c) => c.id === chapterId); - const chapter = chapters[currentIndex]; - - if (!chapter) { - return

Chapter not found

; - } - - const ChapterComponent = chapter.component; - const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; - const nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; - - return ( -
- -

- English Communication -

- -

- {chapter.title} -

- -
- {prevChapter ? ( - - Previous - - ) :
} - - {nextChapter ? ( - - Next - - ) :
} -
- -
- - - -
- {prevChapter ? ( - - {prevChapter.title} - - ) :
} - - {nextChapter ? ( - - {nextChapter.title} - - ) :
} -
-
- ); +import Link from "next/link"; +import { Ch0Content } from "../content/chapter0"; +import { Ch1Content } from "../content/chapter1"; +import { Ch2Content } from "../content/chapter2"; +import { Ch3Content } from "../content/chapter3"; +import { Ch4Content } from "../content/chapter4"; +import { Ch5Content } from "../content/chapter5"; +import { Ch6Content } from "../content/chapter6"; +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { Righteous } from "next/font/google"; + +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +const chapters = [ + { id: "ch0", title: "Course Outline", component: Ch0Content }, + { id: "ch1", title: "Basics of Communication", component: Ch1Content }, + { id: "ch2", title: "Written Communication", component: Ch2Content }, + { id: "ch3", title: "Verbal & Non-Verbal Communication", component: Ch3Content }, + { id: "ch4", title: "Reading Comprehension", component: Ch4Content }, + { id: "ch5", title: "Grammar Essentials", component: Ch5Content }, + { id: "ch6", title: "Presentation & Interview Skills", component: Ch6Content }, +]; + +type ChapterProps = { + params: Promise<{ chapter: string }>; +}; + +export default async function ChapterPage({ params }: ChapterProps) { + const { chapter: chapterId } = await params; + + const currentIndex = chapters.findIndex((c) => c.id === chapterId); + const chapter = chapters[currentIndex]; + + if (!chapter) { + return

Chapter not found

; + } + + const ChapterComponent = chapter.component; + const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; + const nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + + return ( +
+ +

+ English Communication +

+ +

+ {chapter.title} +

+ +
+ {prevChapter ? ( + + Previous + + ) :
} + + {nextChapter ? ( + + Next + + ) :
} +
+ +
+ + + +
+ {prevChapter ? ( + + {prevChapter.title} + + ) :
} + + {nextChapter ? ( + + {nextChapter.title} + + ) :
} +
+
+ ); } \ No newline at end of file diff --git a/app/sem1/ec/page.tsx b/app/sem1/ec/page.tsx index 72cf652..6a96885 100644 --- a/app/sem1/ec/page.tsx +++ b/app/sem1/ec/page.tsx @@ -1,10 +1,10 @@ - -// app/sem1/ec/page.tsx -export default function Home() { - return ( -
-

Welcome to English Communication

-

Select a chapter from the sidebar to get started.

-
- ); -} + +// app/sem1/ec/page.tsx +export default function Home() { + return ( +
+

Welcome to English Communication

+

Select a chapter from the sidebar to get started.

+
+ ); +} diff --git a/app/sem1/em1/[chapter]/page.tsx b/app/sem1/em1/[chapter]/page.tsx index d37247c..9eaf38c 100644 --- a/app/sem1/em1/[chapter]/page.tsx +++ b/app/sem1/em1/[chapter]/page.tsx @@ -1,129 +1,130 @@ -import Link from "next/link"; -import { Ch0Content } from "../content/chapter0"; -import { Ch1Content } from "../content/chapter1"; -import { Ch2Content } from "../content/chapter2"; -import { Ch3Content } from "../content/chapter3"; -import { Ch4Content } from "../content/chapter4"; -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; -import { Righteous } from "next/font/google"; - -import BookmarkButton from "../../../components/BookmarkButton"; -import { moduleQuizzes } from "@/lib/quizData"; -import ChapterQuizInline from "../components/ChapterQuizInline"; -const righteous = Righteous({ - subsets: ["latin"], - weight: "400", - variable: "--font-righteous", -}); - -// Engineering Mathematics I - Chapter Data -const chapters = [ - { id: "ch0", title: "Course Outline", component: Ch0Content }, - { id: "ch1", title: "Differential Calculus", component: Ch1Content }, - { id: "ch2", title: "Linear Algebra", component: Ch2Content }, - { id: "ch3", title: "Ordinary Differential Equations", component: Ch3Content }, - { id: "ch4", title: "Laplace Transforms", component: Ch4Content }, -]; - -type ChapterProps = { - params: { chapter: string }; -}; - -export default function ChapterPage({ params }: ChapterProps) { - const currentIndex = chapters.findIndex((c) => c.id === params.chapter); - const chapter = chapters[currentIndex]; - - if (!chapter) { - return

Chapter not found

; - } - - const ChapterComponent = chapter.component; - const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; - const nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; - - const chapterQuizSlugMap: Record = { - ch1: "em1-differential-calculus", - ch2: "em1-linear-algebra", - ch3: "em1-ordinary-differential-equations", - ch4: "em1-laplace-transforms", - }; - const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[params.chapter]); - - return ( -
- - {/* Title */} -

- Engineering Mathematics I -

- -
-

- {chapter.title} -

- -
- - {/* Top Navigation */} -
- {prevChapter ? ( - - Previous - - ) : ( -
- )} - - {nextChapter ? ( - - Next - - ) : ( -
- )} -
- -
- - {/* Chapter Body */} - - - {chapterQuiz ? ( -
- -
- ) : null} - - {/* Bottom Navigation */} -
- {prevChapter ? ( - - {prevChapter.title} - - ) : ( -
- )} - - {nextChapter ? ( - - {nextChapter.title} - - ) : ( -
- )} -
-
- ); -} +import Link from "next/link"; +import { Ch0Content } from "../content/chapter0"; +import { Ch1Content } from "../content/chapter1"; +import { Ch2Content } from "../content/chapter2"; +import { Ch3Content } from "../content/chapter3"; +import { Ch4Content } from "../content/chapter4"; +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { Righteous } from "next/font/google"; + +import BookmarkButton from "../../../components/BookmarkButton"; +import { moduleQuizzes } from "@/lib/quizData"; +import ChapterQuizInline from "../components/ChapterQuizInline"; +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +// Engineering Mathematics I - Chapter Data +const chapters = [ + { id: "ch0", title: "Course Outline", component: Ch0Content }, + { id: "ch1", title: "Differential Calculus", component: Ch1Content }, + { id: "ch2", title: "Linear Algebra", component: Ch2Content }, + { id: "ch3", title: "Ordinary Differential Equations", component: Ch3Content }, + { id: "ch4", title: "Laplace Transforms", component: Ch4Content }, +]; + +type ChapterProps = { + params: { chapter: string }; +}; + +export default async function ChapterPage({ params }: { params: Promise<{ chapter: string }> }) { + const { chapter } = await params; + const currentIndex = chapters.findIndex((c) => c.id === chapter); + const chapter = chapters[currentIndex]; + + if (!chapter) { + return

Chapter not found

; + } + + const ChapterComponent = chapter.component; + const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; + const nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + + const chapterQuizSlugMap: Record = { + ch1: "em1-differential-calculus", + ch2: "em1-linear-algebra", + ch3: "em1-ordinary-differential-equations", + ch4: "em1-laplace-transforms", + }; + const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[chapter]); + + return ( +
+ + {/* Title */} +

+ Engineering Mathematics I +

+ +
+

+ {chapter.title} +

+ +
+ + {/* Top Navigation */} +
+ {prevChapter ? ( + + Previous + + ) : ( +
+ )} + + {nextChapter ? ( + + Next + + ) : ( +
+ )} +
+ +
+ + {/* Chapter Body */} + + + {chapterQuiz ? ( +
+ +
+ ) : null} + + {/* Bottom Navigation */} +
+ {prevChapter ? ( + + {prevChapter.title} + + ) : ( +
+ )} + + {nextChapter ? ( + + {nextChapter.title} + + ) : ( +
+ )} +
+
+ ); +} diff --git a/app/sem1/em1/page.tsx b/app/sem1/em1/page.tsx index 2ca517d..2530488 100644 --- a/app/sem1/em1/page.tsx +++ b/app/sem1/em1/page.tsx @@ -1,5 +1,5 @@ -import { redirect } from "next/navigation"; - -export default function Page() { - redirect("/sem1/em1/ch0"); -} +import { redirect } from "next/navigation"; + +export default function Page() { + redirect("/sem1/em1/ch0"); +} diff --git a/app/sem1/ep/[chapter]/page.tsx b/app/sem1/ep/[chapter]/page.tsx index 19edea6..848d6f2 100644 --- a/app/sem1/ep/[chapter]/page.tsx +++ b/app/sem1/ep/[chapter]/page.tsx @@ -1,135 +1,136 @@ -import Link from "next/link"; -import { Ch0Content } from "../content/chapter0"; -import { Ch1Content } from "../content/chapter1"; -import { Ch2Content } from "../content/chapter2"; -import { Ch3Content } from "../content/chapter3"; -import { Ch4Content } from "../content/chapter4"; -import { Ch5Content } from "../content/chapter5"; -import ChapterQuizInline from "../components/ChapterQuizInline"; -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; -import { Righteous } from "next/font/google"; - -import BookmarkButton from "../../../components/BookmarkButton"; - -import { moduleQuizzes } from "@/lib/quizData"; -const righteous = Righteous({ - subsets: ['latin'], - weight: '400', - variable: '--font-righteous', -}); - -// Chapter data -const chapters = [ - { id: "ch0", title: "Course Outline", component: Ch0Content }, - { id: "ch1", title: "Vector Algebra & Fields", component: Ch1Content }, - { id: "ch2", title: "Electrostatics & Magnetostatics", component: Ch2Content }, - { id: "ch3", title: "Electrodynamics & Maxwell’s Equations", component: Ch3Content }, - { id: "ch4", title: "Semiconductors & Superconductivity", component: Ch4Content }, - { id: "ch5", title: "LASERs & Optical Fiber", component: Ch5Content }, -]; - -type ChapterProps = { - params: { chapter: string }; -}; - -export default function ChapterPage({ params }: ChapterProps) { - const currentIndex = chapters.findIndex((c) => c.id === params.chapter); - const chapter = chapters[currentIndex]; - - if (!chapter) { - return

Chapter not found

; - } - - const ChapterComponent = chapter.component; - const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; - const nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; - - const chapterQuizSlugMap: Record = { - ch1: "ep-vector-fields", - ch2: "ep-electrostatics-magnetostatics", - ch3: "ep-electrodynamics-maxwell", - ch4: "ep-superconductivity", - ch5: "ep-laser-fibre-optics", - }; - - const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[params.chapter]); - - return ( -
- {/* Content */} -
-

- Engineering Physics -

-
-

- {chapter.title} -

- -
- {/* Navigation Buttons */} -
- {prevChapter ? ( - - Previous - - ) : ( -
- )} - - {nextChapter ? ( - - Next - - ) : ( -
- )} -
- -
- - - {chapterQuiz ? ( -
- -
- ) : null} -
- - {/* Navigation Buttons */} -
- {prevChapter ? ( - - {prevChapter.title} - - ) : ( -
- )} - - {nextChapter ? ( - - {nextChapter.title} - - ) : ( -
- )} -
-
- ); -} +import Link from "next/link"; +import { Ch0Content } from "../content/chapter0"; +import { Ch1Content } from "../content/chapter1"; +import { Ch2Content } from "../content/chapter2"; +import { Ch3Content } from "../content/chapter3"; +import { Ch4Content } from "../content/chapter4"; +import { Ch5Content } from "../content/chapter5"; +import ChapterQuizInline from "../components/ChapterQuizInline"; +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { Righteous } from "next/font/google"; + +import BookmarkButton from "../../../components/BookmarkButton"; + +import { moduleQuizzes } from "@/lib/quizData"; +const righteous = Righteous({ + subsets: ['latin'], + weight: '400', + variable: '--font-righteous', +}); + +// Chapter data +const chapters = [ + { id: "ch0", title: "Course Outline", component: Ch0Content }, + { id: "ch1", title: "Vector Algebra & Fields", component: Ch1Content }, + { id: "ch2", title: "Electrostatics & Magnetostatics", component: Ch2Content }, + { id: "ch3", title: "Electrodynamics & Maxwell’s Equations", component: Ch3Content }, + { id: "ch4", title: "Semiconductors & Superconductivity", component: Ch4Content }, + { id: "ch5", title: "LASERs & Optical Fiber", component: Ch5Content }, +]; + +type ChapterProps = { + params: { chapter: string }; +}; + +export default async function ChapterPage({ params }: { params: Promise<{ chapter: string }> }) { + const { chapter } = await params; + const currentIndex = chapters.findIndex((c) => c.id === chapter); + const chapter = chapters[currentIndex]; + + if (!chapter) { + return

Chapter not found

; + } + + const ChapterComponent = chapter.component; + const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; + const nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + + const chapterQuizSlugMap: Record = { + ch1: "ep-vector-fields", + ch2: "ep-electrostatics-magnetostatics", + ch3: "ep-electrodynamics-maxwell", + ch4: "ep-superconductivity", + ch5: "ep-laser-fibre-optics", + }; + + const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[chapter]); + + return ( +
+ {/* Content */} +
+

+ Engineering Physics +

+
+

+ {chapter.title} +

+ +
+ {/* Navigation Buttons */} +
+ {prevChapter ? ( + + Previous + + ) : ( +
+ )} + + {nextChapter ? ( + + Next + + ) : ( +
+ )} +
+ +
+ + + {chapterQuiz ? ( +
+ +
+ ) : null} +
+ + {/* Navigation Buttons */} +
+ {prevChapter ? ( + + {prevChapter.title} + + ) : ( +
+ )} + + {nextChapter ? ( + + {nextChapter.title} + + ) : ( +
+ )} +
+
+ ); +} diff --git a/app/sem1/ep/page.tsx b/app/sem1/ep/page.tsx index 5217c7f..8d3a613 100644 --- a/app/sem1/ep/page.tsx +++ b/app/sem1/ep/page.tsx @@ -1,5 +1,5 @@ -import { redirect } from "next/navigation"; - -export default function Page() { - redirect("/sem1/ep/ch0"); -} +import { redirect } from "next/navigation"; + +export default function Page() { + redirect("/sem1/ep/ch0"); +} diff --git a/app/sem2/dsc/[chapter]/page.tsx b/app/sem2/dsc/[chapter]/page.tsx index 494c84d..10a153b 100644 --- a/app/sem2/dsc/[chapter]/page.tsx +++ b/app/sem2/dsc/[chapter]/page.tsx @@ -1,132 +1,133 @@ -import Link from "next/link"; -import { Righteous } from "next/font/google"; -import BookmarkButton from "../../../components/BookmarkButton"; - -import { Ch0Content } from "../content/chapter0"; -import { Ch1Content } from "../content/chapter1"; -import { Ch2Content } from "../content/chapter2"; -import { Ch3Content } from "../content/chapter3"; -import { Ch4Content } from "../content/chapter4"; - -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; -import { moduleQuizzes } from "@/lib/quizData"; -import ChapterQuizInline from "../components/ChapterQuizInline"; - -const righteous = Righteous({ - subsets: ["latin"], - weight: "400", - variable: "--font-righteous", -}); - -const chapters = [ - { id: "ch0", title: "Course Outline", component: Ch0Content }, - { id: "ch1", title: "Arrays", component: Ch1Content }, - { id: "ch2", title: "Linked Lists", component: Ch2Content }, - { id: "ch3", title: "Stacks", component: Ch3Content }, - { id: "ch4", title: "Queues", component: Ch4Content }, -]; - -type ChapterProps = { - params: { chapter: string }; -}; - -export default function ChapterPage({ params }: ChapterProps) { - const currentIndex = chapters.findIndex((c) => c.id === params.chapter); - const chapter = chapters[currentIndex]; - - if (!chapter) { - return

Chapter not found

; - } - - const ChapterComponent = chapter.component; - const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; - const nextChapter = - currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; - - const chapterQuizSlugMap: Record = { - ch1: "dsc-arrays", - }; - const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[params.chapter]); - - return ( -
- -
-

- Data Structures using C -

- -
-

- {chapter.title} -

- -
- - {/* Navigation */} -
- {prevChapter ? ( - - Previous - - ) : ( -
- )} - - {nextChapter ? ( - - Next - - ) : ( -
- )} -
- -
- - - {chapterQuiz ? ( -
- -
- ) : null} -
- - {/* Bottom Navigation */} -
- {prevChapter ? ( - - {prevChapter.title} - - ) : ( -
- )} - - {nextChapter ? ( - - {nextChapter.title}{" "} - - - ) : ( -
- )} -
-
- ); -} +import Link from "next/link"; +import { Righteous } from "next/font/google"; +import BookmarkButton from "../../../components/BookmarkButton"; + +import { Ch0Content } from "../content/chapter0"; +import { Ch1Content } from "../content/chapter1"; +import { Ch2Content } from "../content/chapter2"; +import { Ch3Content } from "../content/chapter3"; +import { Ch4Content } from "../content/chapter4"; + +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { moduleQuizzes } from "@/lib/quizData"; +import ChapterQuizInline from "../components/ChapterQuizInline"; + +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +const chapters = [ + { id: "ch0", title: "Course Outline", component: Ch0Content }, + { id: "ch1", title: "Arrays", component: Ch1Content }, + { id: "ch2", title: "Linked Lists", component: Ch2Content }, + { id: "ch3", title: "Stacks", component: Ch3Content }, + { id: "ch4", title: "Queues", component: Ch4Content }, +]; + +type ChapterProps = { + params: { chapter: string }; +}; + +export default async function ChapterPage({ params }: { params: Promise<{ chapter: string }> }) { + const { chapter } = await params; + const currentIndex = chapters.findIndex((c) => c.id === chapter); + const chapter = chapters[currentIndex]; + + if (!chapter) { + return

Chapter not found

; + } + + const ChapterComponent = chapter.component; + const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; + const nextChapter = + currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + + const chapterQuizSlugMap: Record = { + ch1: "dsc-arrays", + }; + const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[chapter]); + + return ( +
+ +
+

+ Data Structures using C +

+ +
+

+ {chapter.title} +

+ +
+ + {/* Navigation */} +
+ {prevChapter ? ( + + Previous + + ) : ( +
+ )} + + {nextChapter ? ( + + Next + + ) : ( +
+ )} +
+ +
+ + + {chapterQuiz ? ( +
+ +
+ ) : null} +
+ + {/* Bottom Navigation */} +
+ {prevChapter ? ( + + {prevChapter.title} + + ) : ( +
+ )} + + {nextChapter ? ( + + {nextChapter.title}{" "} + + + ) : ( +
+ )} +
+
+ ); +} diff --git a/app/sem2/dsc/page.tsx b/app/sem2/dsc/page.tsx index c80f3ad..ab2244f 100644 --- a/app/sem2/dsc/page.tsx +++ b/app/sem2/dsc/page.tsx @@ -1,5 +1,5 @@ -import { redirect } from "next/navigation"; - -export default function Page() { - redirect("/sem2/dsc/ch0"); -} +import { redirect } from "next/navigation"; + +export default function Page() { + redirect("/sem2/dsc/ch0"); +} diff --git a/app/sem2/em2/[chapter]/page.tsx b/app/sem2/em2/[chapter]/page.tsx index a980a88..d4eb707 100644 --- a/app/sem2/em2/[chapter]/page.tsx +++ b/app/sem2/em2/[chapter]/page.tsx @@ -1,132 +1,133 @@ -import Link from "next/link"; -import { Ch0Content } from "../content/chapter0"; -import { Ch1Content } from "../content/chapter1"; -import { Ch2Content } from "../content/chapter2"; -import { Ch3Content } from "../content/chapter3"; -import { Ch4Content } from "../content/chapter4"; -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; -import { Righteous } from "next/font/google"; -import BookmarkButton from "../../../components/BookmarkButton"; - -import { moduleQuizzes } from "@/lib/quizData"; -import ChapterQuizInline from "../components/ChapterQuizInline"; - -const righteous = Righteous({ - subsets: ["latin"], - weight: "400", - variable: "--font-righteous", -}); - -const chapters = [ - { id: "ch0", title: "Course Outline", component: Ch0Content }, - { id: "ch1", title: "Sequences and Series", component: Ch1Content }, - { id: "ch2", title: "Numerical Analysis", component: Ch2Content }, - { id: "ch3", title: "Complex Variables", component: Ch3Content }, - { id: "ch4", title: "Integral Calculus", component: Ch4Content }, -]; - -type ChapterProps = { - params: { chapter: string }; -}; - -export default function ChapterPage({ params }: ChapterProps) { - const currentIndex = chapters.findIndex((c) => c.id === params.chapter); - const chapter = chapters[currentIndex]; - - if (!chapter) { - return

Chapter not found

; - } - - const ChapterComponent = chapter.component; - const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; - const nextChapter = - currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; - - const chapterQuizSlugMap: Record = { - ch1: "em2-sequences-series", - ch2: "em2-numerical-analysis", - ch3: "em2-complex-variables", - ch4: "em2-integral-calculus", - }; - const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[params.chapter]); - - return ( -
- -

- Engineering Mathematics II -

- -
-

- {chapter.title} -

- -
- - {/* Top Navigation */} -
- {prevChapter ? ( - - Previous - - ) : ( -
- )} - - {nextChapter ? ( - - Next - - ) : ( -
- )} -
- -
- - - - {chapterQuiz ? ( -
- -
- ) : null} - - {/* Bottom Navigation */} -
- {prevChapter ? ( - - {prevChapter.title} - - ) : ( -
- )} - - {nextChapter ? ( - - {nextChapter.title} - - ) : ( -
- )} -
-
- ); -} +import Link from "next/link"; +import { Ch0Content } from "../content/chapter0"; +import { Ch1Content } from "../content/chapter1"; +import { Ch2Content } from "../content/chapter2"; +import { Ch3Content } from "../content/chapter3"; +import { Ch4Content } from "../content/chapter4"; +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { Righteous } from "next/font/google"; +import BookmarkButton from "../../../components/BookmarkButton"; + +import { moduleQuizzes } from "@/lib/quizData"; +import ChapterQuizInline from "../components/ChapterQuizInline"; + +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +const chapters = [ + { id: "ch0", title: "Course Outline", component: Ch0Content }, + { id: "ch1", title: "Sequences and Series", component: Ch1Content }, + { id: "ch2", title: "Numerical Analysis", component: Ch2Content }, + { id: "ch3", title: "Complex Variables", component: Ch3Content }, + { id: "ch4", title: "Integral Calculus", component: Ch4Content }, +]; + +type ChapterProps = { + params: { chapter: string }; +}; + +export default async function ChapterPage({ params }: { params: Promise<{ chapter: string }> }) { + const { chapter } = await params; + const currentIndex = chapters.findIndex((c) => c.id === chapter); + const chapter = chapters[currentIndex]; + + if (!chapter) { + return

Chapter not found

; + } + + const ChapterComponent = chapter.component; + const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; + const nextChapter = + currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + + const chapterQuizSlugMap: Record = { + ch1: "em2-sequences-series", + ch2: "em2-numerical-analysis", + ch3: "em2-complex-variables", + ch4: "em2-integral-calculus", + }; + const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[chapter]); + + return ( +
+ +

+ Engineering Mathematics II +

+ +
+

+ {chapter.title} +

+ +
+ + {/* Top Navigation */} +
+ {prevChapter ? ( + + Previous + + ) : ( +
+ )} + + {nextChapter ? ( + + Next + + ) : ( +
+ )} +
+ +
+ + + + {chapterQuiz ? ( +
+ +
+ ) : null} + + {/* Bottom Navigation */} +
+ {prevChapter ? ( + + {prevChapter.title} + + ) : ( +
+ )} + + {nextChapter ? ( + + {nextChapter.title} + + ) : ( +
+ )} +
+
+ ); +} diff --git a/app/sem2/em2/page.tsx b/app/sem2/em2/page.tsx index 51bbffa..e85da69 100644 --- a/app/sem2/em2/page.tsx +++ b/app/sem2/em2/page.tsx @@ -1,5 +1,5 @@ -import { redirect } from "next/navigation"; - -export default function Page() { - redirect("/sem2/em2/ch0"); -} +import { redirect } from "next/navigation"; + +export default function Page() { + redirect("/sem2/em2/ch0"); +} diff --git a/app/sem2/oops/[chapter]/page.tsx b/app/sem2/oops/[chapter]/page.tsx index 693e000..58883a1 100644 --- a/app/sem2/oops/[chapter]/page.tsx +++ b/app/sem2/oops/[chapter]/page.tsx @@ -1,145 +1,146 @@ -import Link from "next/link"; -import { Righteous } from "next/font/google"; - -import { Ch0Content } from "../content/chapter0"; -import { Ch1Content } from "../content/chapter1"; -import { Ch2Content } from "../content/chapter2"; -import { Ch3Content } from "../content/chapter3"; -import { Ch4Content } from "../content/chapter4"; -import { Ch5Content } from "../content/chapter5"; -import { Ch6Content } from "../content/chapter6"; -import { Ch7Content } from "../content/chapter7"; -import { Ch8Content } from "../content/chapter8"; -import BookmarkButton from "../../../components/BookmarkButton"; -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; -import { moduleQuizzes } from "@/lib/quizData"; -import ChapterQuizInline from "../components/ChapterQuizInline"; - -const righteous = Righteous({ - subsets: ["latin"], - weight: "400", - variable: "--font-righteous", -}); - -const chapters = [ - { id: "ch0", title: "Course Outline", component: Ch0Content }, - { id: "ch1", title: "Introduction to Java", component: Ch1Content }, - { id: "ch2", title: "Classes and Objects", component: Ch2Content }, - { id: "ch3", title: "Inheritance & Polymorphism", component: Ch3Content }, - { id: "ch4", title: "Packages & Interfaces", component: Ch4Content }, - { id: "ch5", title: "Exception Handling", component: Ch5Content }, - { id: "ch6", title: "Threads", component: Ch6Content }, - { id: "ch7", title: "Generics", component: Ch7Content }, - { id: "ch8", title: "Java Library & Swing GUI", component: Ch8Content }, -]; - -type ChapterProps = { - params: { chapter: string }; -}; - -export default function ChapterPage({ params }: ChapterProps) { - const currentIndex = chapters.findIndex((c) => c.id === params.chapter); - const chapter = chapters[currentIndex]; - - if (!chapter) { - return

Chapter not found

; - } - - const ChapterComponent = chapter.component; - const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; - const nextChapter = - currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; - - const chapterQuizSlugMap: Record = { - ch1: "oops-intro-java", - ch2: "oops-classes-objects", - ch3: "oops-inheritance-polymorphism", - ch4: "oops-packages-interfaces", - ch5: "oops-exception-handling", - ch6: "oops-threads", - ch7: "oops-generics", - ch8: "oops-java-lib-swing", - }; - const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[params.chapter]); - - return ( -
- -
-

- Object-Oriented Programming in Java -

- -
-

- {chapter.title} -

- -
- {/* Navigation */} -
- {prevChapter ? ( - - Previous - - ) : ( -
- )} - - {nextChapter ? ( - - Next - - ) : ( -
- )} -
- -
- - - {chapterQuiz ? ( -
- -
- ) : null} -
- - {/* Bottom Navigation */} -
- {prevChapter ? ( - - {prevChapter.title} - - ) : ( -
- )} - - {nextChapter ? ( - - {nextChapter.title}{" "} - - - ) : ( -
- )} -
-
- ); -} +import Link from "next/link"; +import { Righteous } from "next/font/google"; + +import { Ch0Content } from "../content/chapter0"; +import { Ch1Content } from "../content/chapter1"; +import { Ch2Content } from "../content/chapter2"; +import { Ch3Content } from "../content/chapter3"; +import { Ch4Content } from "../content/chapter4"; +import { Ch5Content } from "../content/chapter5"; +import { Ch6Content } from "../content/chapter6"; +import { Ch7Content } from "../content/chapter7"; +import { Ch8Content } from "../content/chapter8"; +import BookmarkButton from "../../../components/BookmarkButton"; +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { moduleQuizzes } from "@/lib/quizData"; +import ChapterQuizInline from "../components/ChapterQuizInline"; + +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +const chapters = [ + { id: "ch0", title: "Course Outline", component: Ch0Content }, + { id: "ch1", title: "Introduction to Java", component: Ch1Content }, + { id: "ch2", title: "Classes and Objects", component: Ch2Content }, + { id: "ch3", title: "Inheritance & Polymorphism", component: Ch3Content }, + { id: "ch4", title: "Packages & Interfaces", component: Ch4Content }, + { id: "ch5", title: "Exception Handling", component: Ch5Content }, + { id: "ch6", title: "Threads", component: Ch6Content }, + { id: "ch7", title: "Generics", component: Ch7Content }, + { id: "ch8", title: "Java Library & Swing GUI", component: Ch8Content }, +]; + +type ChapterProps = { + params: { chapter: string }; +}; + +export default async function ChapterPage({ params }: { params: Promise<{ chapter: string }> }) { + const { chapter } = await params; + const currentIndex = chapters.findIndex((c) => c.id === chapter); + const chapter = chapters[currentIndex]; + + if (!chapter) { + return

Chapter not found

; + } + + const ChapterComponent = chapter.component; + const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; + const nextChapter = + currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + + const chapterQuizSlugMap: Record = { + ch1: "oops-intro-java", + ch2: "oops-classes-objects", + ch3: "oops-inheritance-polymorphism", + ch4: "oops-packages-interfaces", + ch5: "oops-exception-handling", + ch6: "oops-threads", + ch7: "oops-generics", + ch8: "oops-java-lib-swing", + }; + const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[chapter]); + + return ( +
+ +
+

+ Object-Oriented Programming in Java +

+ +
+

+ {chapter.title} +

+ +
+ {/* Navigation */} +
+ {prevChapter ? ( + + Previous + + ) : ( +
+ )} + + {nextChapter ? ( + + Next + + ) : ( +
+ )} +
+ +
+ + + {chapterQuiz ? ( +
+ +
+ ) : null} +
+ + {/* Bottom Navigation */} +
+ {prevChapter ? ( + + {prevChapter.title} + + ) : ( +
+ )} + + {nextChapter ? ( + + {nextChapter.title}{" "} + + + ) : ( +
+ )} +
+
+ ); +} diff --git a/app/sem2/oops/page.tsx b/app/sem2/oops/page.tsx index 1810f1d..4f0faea 100644 --- a/app/sem2/oops/page.tsx +++ b/app/sem2/oops/page.tsx @@ -1,5 +1,5 @@ -import { redirect } from "next/navigation"; - -export default function Page() { - redirect("/sem2/oops/ch0"); -} +import { redirect } from "next/navigation"; + +export default function Page() { + redirect("/sem2/oops/ch0"); +} diff --git a/app/sem3/coa/[chapter]/page.tsx b/app/sem3/coa/[chapter]/page.tsx index 1ac3bbd..5f62db2 100644 --- a/app/sem3/coa/[chapter]/page.tsx +++ b/app/sem3/coa/[chapter]/page.tsx @@ -1,117 +1,118 @@ -import Link from "next/link"; -import { Ch0Content } from "../content/chapter0"; -import { Ch1Content } from "../content/chapter1"; -import { Ch2Content } from "../content/chapter2"; -import { Ch3Content } from "../content/chapter3"; -import { Ch4Content } from "../content/chapter4"; -import { Ch5Content } from "../content/chapter5"; -import { Ch6Content } from "../content/chapter6"; -import { Ch7Content } from "../content/chapter7"; -import { Ch8Content } from "../content/chapter8"; -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; -import { Righteous } from "next/font/google"; - -const righteous = Righteous({ - subsets: ['latin'], - weight: '400', - variable: '--font-righteous', - }); - -// Chapter data -const chapters = [ - { id: "ch0", title: "Course Outline", component: Ch0Content }, - { id: "ch1", title: "Introduction to Computer Architecture", component: Ch1Content }, - { id: "ch2", title: "Performance Analysis", component: Ch2Content }, - { id: "ch3", title: "MIPS - Language of the Computer", component: Ch3Content }, - { id: "ch4", title: "Computer Arithmetic", component: Ch4Content }, - { id: "ch5", title: "Building a Datapath", component: Ch5Content }, - { id: "ch6", title: "Pipelining", component: Ch6Content }, - { id: "ch7", title: "Memory Hierarchy", component: Ch7Content }, - { id: "ch8", title: "Storage and I/O Systems", component: Ch8Content }, -]; - -type ChapterProps = { - params: { chapter: string }; -}; - -export default function ChapterPage({ params }: ChapterProps) { - const currentIndex = chapters.findIndex((c) => c.id === params.chapter); - const chapter = chapters[currentIndex]; - - if (!chapter) { - return

Chapter not found

; - } - - const ChapterComponent = chapter.component; - const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; - const nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; - - return ( -
- {/* Content */} -
-

- Computer Organization and Architecture -

-

{chapter.title}

- - {/* Navigation Buttons */} -
- {prevChapter ? ( - - Previous - - ) : ( -
- )} - - {nextChapter ? ( - - Next - - ) : ( -
- )} -
- -
- -
- - {/* Navigation Buttons */} -
- {prevChapter ? ( - - {prevChapter.title} - - ) : ( -
- )} - - {nextChapter ? ( - - {nextChapter.title} - - ) : ( -
- )} -
-
- ); -} +import Link from "next/link"; +import { Ch0Content } from "../content/chapter0"; +import { Ch1Content } from "../content/chapter1"; +import { Ch2Content } from "../content/chapter2"; +import { Ch3Content } from "../content/chapter3"; +import { Ch4Content } from "../content/chapter4"; +import { Ch5Content } from "../content/chapter5"; +import { Ch6Content } from "../content/chapter6"; +import { Ch7Content } from "../content/chapter7"; +import { Ch8Content } from "../content/chapter8"; +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { Righteous } from "next/font/google"; + +const righteous = Righteous({ + subsets: ['latin'], + weight: '400', + variable: '--font-righteous', + }); + +// Chapter data +const chapters = [ + { id: "ch0", title: "Course Outline", component: Ch0Content }, + { id: "ch1", title: "Introduction to Computer Architecture", component: Ch1Content }, + { id: "ch2", title: "Performance Analysis", component: Ch2Content }, + { id: "ch3", title: "MIPS - Language of the Computer", component: Ch3Content }, + { id: "ch4", title: "Computer Arithmetic", component: Ch4Content }, + { id: "ch5", title: "Building a Datapath", component: Ch5Content }, + { id: "ch6", title: "Pipelining", component: Ch6Content }, + { id: "ch7", title: "Memory Hierarchy", component: Ch7Content }, + { id: "ch8", title: "Storage and I/O Systems", component: Ch8Content }, +]; + +type ChapterProps = { + params: { chapter: string }; +}; + +export default async function ChapterPage({ params }: { params: Promise<{ chapter: string }> }) { + const { chapter } = await params; + const currentIndex = chapters.findIndex((c) => c.id === chapter); + const chapter = chapters[currentIndex]; + + if (!chapter) { + return

Chapter not found

; + } + + const ChapterComponent = chapter.component; + const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; + const nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + + return ( +
+ {/* Content */} +
+

+ Computer Organization and Architecture +

+

{chapter.title}

+ + {/* Navigation Buttons */} +
+ {prevChapter ? ( + + Previous + + ) : ( +
+ )} + + {nextChapter ? ( + + Next + + ) : ( +
+ )} +
+ +
+ +
+ + {/* Navigation Buttons */} +
+ {prevChapter ? ( + + {prevChapter.title} + + ) : ( +
+ )} + + {nextChapter ? ( + + {nextChapter.title} + + ) : ( +
+ )} +
+
+ ); +} diff --git a/app/sem3/coa/page.tsx b/app/sem3/coa/page.tsx index 02c511b..ce64884 100644 --- a/app/sem3/coa/page.tsx +++ b/app/sem3/coa/page.tsx @@ -1,5 +1,5 @@ -import { redirect } from "next/navigation"; - -export default function Page() { - redirect("/sem3/coa/ch0"); -} +import { redirect } from "next/navigation"; + +export default function Page() { + redirect("/sem3/coa/ch0"); +} diff --git a/app/sem4/dbms/[chapter]/page.tsx b/app/sem4/dbms/[chapter]/page.tsx index 550df44..ae00cbe 100644 --- a/app/sem4/dbms/[chapter]/page.tsx +++ b/app/sem4/dbms/[chapter]/page.tsx @@ -1,118 +1,119 @@ -import Link from "next/link"; -import { Ch0Content } from "../content/chapter0"; -import { Ch1Content } from "../content/chapter1"; -import { Ch2Content } from "../content/chapter2"; -import { Ch3Content } from "../content/chapter3"; -import BookmarkButton from "../../../components/BookmarkButton"; -// import { Ch4Content } from "../content/chapter4"; -// import { Ch5Content } from "../content/chapter5"; -// import { Ch6Content } from "../content/chapter6"; -// import { Ch7Content } from "../content/chapter7"; -// import { Ch8Content } from "../content/chapter8"; - -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; -import { Righteous } from "next/font/google"; - -const righteous = Righteous({ - subsets: ["latin"], - weight: "400", - variable: "--font-righteous", -}); - -const chapters = [ - { id: "ch0", title: "Course Outline", component: Ch0Content }, - { id: "ch1", title: "Introduction to Databases", component: Ch1Content }, - { id: "ch2", title: "Entity-Relationship Model", component: Ch2Content }, - { id: "ch3", title: "Relational Model and SQL", component: Ch3Content }, - // { id: "ch4", title: "Normalization", component: Ch4Content }, - // { id: "ch5", title: "Transactions and Concurrency Control", component: Ch5Content }, - // { id: "ch6", title: "Indexing and Hashing", component: Ch6Content }, - // { id: "ch7", title: "Query Processing and Optimization", component: Ch7Content }, - // { id: "ch8", title: "Recovery and Security", component: Ch8Content }, -]; - -type ChapterProps = { - params: { chapter: string }; -}; - -export default function ChapterPage({ params }: ChapterProps) { - const currentIndex = chapters.findIndex((c) => c.id === params.chapter); - const chapter = chapters[currentIndex]; - - if (!chapter) { - return

Chapter not found

; - } - - const ChapterComponent = chapter.component; - const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; - const nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; - - return ( -
-
-

- Database Management Systems -

- -
-

- {chapter.title} -

- -
- -
- {prevChapter ? ( - - - Previous - - ) :
} - - {nextChapter ? ( - - Next - - - ) :
} -
- -
- - -
- -
- {prevChapter ? ( - - - {prevChapter.title} - - ) :
} - - {nextChapter ? ( - - {nextChapter.title} - - - ) :
} -
-
- ); +import Link from "next/link"; +import { Ch0Content } from "../content/chapter0"; +import { Ch1Content } from "../content/chapter1"; +import { Ch2Content } from "../content/chapter2"; +import { Ch3Content } from "../content/chapter3"; +import BookmarkButton from "../../../components/BookmarkButton"; +// import { Ch4Content } from "../content/chapter4"; +// import { Ch5Content } from "../content/chapter5"; +// import { Ch6Content } from "../content/chapter6"; +// import { Ch7Content } from "../content/chapter7"; +// import { Ch8Content } from "../content/chapter8"; + +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { Righteous } from "next/font/google"; + +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +const chapters = [ + { id: "ch0", title: "Course Outline", component: Ch0Content }, + { id: "ch1", title: "Introduction to Databases", component: Ch1Content }, + { id: "ch2", title: "Entity-Relationship Model", component: Ch2Content }, + { id: "ch3", title: "Relational Model and SQL", component: Ch3Content }, + // { id: "ch4", title: "Normalization", component: Ch4Content }, + // { id: "ch5", title: "Transactions and Concurrency Control", component: Ch5Content }, + // { id: "ch6", title: "Indexing and Hashing", component: Ch6Content }, + // { id: "ch7", title: "Query Processing and Optimization", component: Ch7Content }, + // { id: "ch8", title: "Recovery and Security", component: Ch8Content }, +]; + +type ChapterProps = { + params: { chapter: string }; +}; + +export default async function ChapterPage({ params }: { params: Promise<{ chapter: string }> }) { + const { chapter } = await params; + const currentIndex = chapters.findIndex((c) => c.id === chapter); + const chapter = chapters[currentIndex]; + + if (!chapter) { + return

Chapter not found

; + } + + const ChapterComponent = chapter.component; + const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; + const nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + + return ( +
+
+

+ Database Management Systems +

+ +
+

+ {chapter.title} +

+ +
+ +
+ {prevChapter ? ( + + + Previous + + ) :
} + + {nextChapter ? ( + + Next + + + ) :
} +
+ +
+ + +
+ +
+ {prevChapter ? ( + + + {prevChapter.title} + + ) :
} + + {nextChapter ? ( + + {nextChapter.title} + + + ) :
} +
+
+ ); } \ No newline at end of file diff --git a/app/sem4/dbms/page.tsx b/app/sem4/dbms/page.tsx index 56d6866..f588c78 100644 --- a/app/sem4/dbms/page.tsx +++ b/app/sem4/dbms/page.tsx @@ -1,5 +1,5 @@ -import { redirect } from "next/navigation"; - -export default function Page() { - redirect("/sem4/dbms/ch0"); -} +import { redirect } from "next/navigation"; + +export default function Page() { + redirect("/sem4/dbms/ch0"); +} diff --git a/app/sem4/dops/[chapter]/page.tsx b/app/sem4/dops/[chapter]/page.tsx index 17def06..15d5816 100644 --- a/app/sem4/dops/[chapter]/page.tsx +++ b/app/sem4/dops/[chapter]/page.tsx @@ -1,126 +1,127 @@ -import Link from "next/link"; -import { Righteous } from "next/font/google"; -import BookmarkButton from "../../../components/BookmarkButton"; -import { Ch0Content } from "../content/chapter0"; -import { Ch1Content } from "../content/chapter1"; -import { Ch2Content } from "../content/chapter2"; -import { Ch3Content } from "../content/chapter3"; -import { Ch4Content } from "../content/chapter4"; -import { Ch5Content } from "../content/chapter5"; -import { Ch6Content } from "../content/chapter6"; -import { Ch7Content } from "../content/chapter7"; -import { Ch8Content } from "../content/chapter8"; - -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; - -const righteous = Righteous({ - subsets: ["latin"], - weight: "400", - variable: "--font-righteous", -}); - -const chapters = [ - { id: "ch0", title: "Course Outline", component: Ch0Content }, - { id: "ch1", title: "Introduction to Linux", component: Ch1Content }, - { id: "ch2", title: "Linux Terminal & File System", component: Ch2Content }, - { id: "ch3", title: "Basic Linux Commands", component: Ch3Content }, - { id: "ch4", title: "Users, Permissions & Packages", component: Ch4Content }, - { id: "ch5", title: "Shell Scripting Basics", component: Ch5Content }, - { id: "ch6", title: "Git & GitHub Basics", component: Ch6Content }, - { id: "ch7", title: "Introduction to DevOps", component: Ch7Content }, - { id: "ch8", title: "CI/CD, Docker & Cloud Basics", component: Ch8Content }, -]; - -type ChapterProps = { - params: { chapter: string }; -}; - -export default function ChapterPage({ params }: ChapterProps) { - const currentIndex = chapters.findIndex((c) => c.id === params.chapter); - const chapter = chapters[currentIndex]; - - if (!chapter) { - return

Chapter not found

; - } - - const ChapterComponent = chapter.component; - const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; - const nextChapter = - currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; - - return ( -
- -
-

- DevOps & Linux Administration -

- -
-

- {chapter.title} -

- -
- - {/* Navigation */} -
- {prevChapter ? ( - - Previous - - ) : ( -
- )} - - {nextChapter ? ( - - Next - - ) : ( -
- )} -
- -
- -
- - {/* Bottom Navigation */} -
- {prevChapter ? ( - - {prevChapter.title} - - ) : ( -
- )} - - {nextChapter ? ( - - {nextChapter.title}{" "} - - - ) : ( -
- )} -
-
- ); +import Link from "next/link"; +import { Righteous } from "next/font/google"; +import BookmarkButton from "../../../components/BookmarkButton"; +import { Ch0Content } from "../content/chapter0"; +import { Ch1Content } from "../content/chapter1"; +import { Ch2Content } from "../content/chapter2"; +import { Ch3Content } from "../content/chapter3"; +import { Ch4Content } from "../content/chapter4"; +import { Ch5Content } from "../content/chapter5"; +import { Ch6Content } from "../content/chapter6"; +import { Ch7Content } from "../content/chapter7"; +import { Ch8Content } from "../content/chapter8"; + +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; + +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +const chapters = [ + { id: "ch0", title: "Course Outline", component: Ch0Content }, + { id: "ch1", title: "Introduction to Linux", component: Ch1Content }, + { id: "ch2", title: "Linux Terminal & File System", component: Ch2Content }, + { id: "ch3", title: "Basic Linux Commands", component: Ch3Content }, + { id: "ch4", title: "Users, Permissions & Packages", component: Ch4Content }, + { id: "ch5", title: "Shell Scripting Basics", component: Ch5Content }, + { id: "ch6", title: "Git & GitHub Basics", component: Ch6Content }, + { id: "ch7", title: "Introduction to DevOps", component: Ch7Content }, + { id: "ch8", title: "CI/CD, Docker & Cloud Basics", component: Ch8Content }, +]; + +type ChapterProps = { + params: { chapter: string }; +}; + +export default async function ChapterPage({ params }: { params: Promise<{ chapter: string }> }) { + const { chapter } = await params; + const currentIndex = chapters.findIndex((c) => c.id === chapter); + const chapter = chapters[currentIndex]; + + if (!chapter) { + return

Chapter not found

; + } + + const ChapterComponent = chapter.component; + const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; + const nextChapter = + currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + + return ( +
+ +
+

+ DevOps & Linux Administration +

+ +
+

+ {chapter.title} +

+ +
+ + {/* Navigation */} +
+ {prevChapter ? ( + + Previous + + ) : ( +
+ )} + + {nextChapter ? ( + + Next + + ) : ( +
+ )} +
+ +
+ +
+ + {/* Bottom Navigation */} +
+ {prevChapter ? ( + + {prevChapter.title} + + ) : ( +
+ )} + + {nextChapter ? ( + + {nextChapter.title}{" "} + + + ) : ( +
+ )} +
+
+ ); } \ No newline at end of file diff --git a/app/sem4/dops/page.tsx b/app/sem4/dops/page.tsx index 3fd0f63..dc2f069 100644 --- a/app/sem4/dops/page.tsx +++ b/app/sem4/dops/page.tsx @@ -1,5 +1,5 @@ -import { redirect } from "next/navigation"; - -export default function Page() { - redirect("/sem4/dops/ch0"); -} +import { redirect } from "next/navigation"; + +export default function Page() { + redirect("/sem4/dops/ch0"); +} diff --git a/app/sem4/os/[chapter]/page.tsx b/app/sem4/os/[chapter]/page.tsx index b1e1944..f5e5e85 100644 --- a/app/sem4/os/[chapter]/page.tsx +++ b/app/sem4/os/[chapter]/page.tsx @@ -1,209 +1,210 @@ -import Link from "next/link"; -import { Ch0Content } from "../content/chapter0"; -import { Ch1Content } from "../content/chapter1"; -import { Ch2Content } from "../content/chapter2"; -import { Ch3Content } from "../content/chapter3"; -import { Ch4Content } from "../content/chapter4"; -import { Ch5Content } from "../content/chapter5"; -import { Ch6Content } from "../content/chapter6"; -import { Ch7Content } from "../content/chapter7"; -import { Ch8Content } from "../content/chapter8"; -import BookmarkButton from "../../../components/BookmarkButton"; - - -import ChapterQuizInline from "../components/ChapterQuizInline"; -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; -import { Righteous } from "next/font/google"; -import { moduleQuizzes } from "@/lib/quizData"; - -const righteous = Righteous({ - subsets: ["latin"], - weight: "400", - variable: "--font-righteous", -}); - -// Chapter data -const chapters = [ - { id: "ch0", title: "Course Outline", component: Ch0Content }, - - { - id: "ch1", - title: "Introduction to Operating Systems", - component: Ch1Content, - }, - - { - id: "ch2", - title: "Process Management", - component: Ch2Content, - }, - - { - id: "ch3", - title: "CPU Scheduling", - component: Ch3Content, - }, - - { - id: "ch4", - title: "Process Synchronization", - component: Ch4Content, - }, - - { - id: "ch5", - title: "Deadlocks", - component: Ch5Content, - }, - - { - id: "ch6", - title: "Memory Management", - component: Ch6Content, - }, - - { - id: "ch7", - title: "Paging and Segmentation", - component: Ch7Content, - }, - - { - id: "ch8", - title: "File Systems and I/O Management", - component: Ch8Content, - }, -]; - -type ChapterProps = { - params: { chapter: string }; -}; - -export default function ChapterPage({ params }: ChapterProps) { - const currentIndex = chapters.findIndex( - (c) => c.id === params.chapter - ); - - const chapter = chapters[currentIndex]; - - if (!chapter) { - return ( -

- Chapter not found -

- ); - } - - const ChapterComponent = chapter.component; - - const prevChapter = - currentIndex > 0 - ? chapters[currentIndex - 1] - : null; - - const nextChapter = - currentIndex < chapters.length - 1 - ? chapters[currentIndex + 1] - : null; - - const chapterQuizSlugMap: Record = { - ch1: "os-intro", - ch2: "os-processes", - ch3: "os-scheduling", - ch4: "os-synchronization", - ch5: "os-deadlock", - ch6: "os-memory-management", - ch7: "os-paging-segmentation", - ch8: "os-file-io", - }; - - const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[params.chapter]); - - return ( -
- {/* Content */} -
-

- Operating System -

- -
-

- {chapter.title} -

- -
- - {/* Top Navigation */} -
- {prevChapter ? ( - - - Previous - - ) : ( -
- )} - - {nextChapter ? ( - - Next - - - ) : ( -
- )} -
- -
- - - - {chapterQuiz ? ( -
- -
- ) : null} -
- - {/* Bottom Navigation */} -
- {prevChapter ? ( - - - {prevChapter.title} - - ) : ( -
- )} - - {nextChapter ? ( - - {nextChapter.title} - - - ) : ( -
- )} -
-
- ); +import Link from "next/link"; +import { Ch0Content } from "../content/chapter0"; +import { Ch1Content } from "../content/chapter1"; +import { Ch2Content } from "../content/chapter2"; +import { Ch3Content } from "../content/chapter3"; +import { Ch4Content } from "../content/chapter4"; +import { Ch5Content } from "../content/chapter5"; +import { Ch6Content } from "../content/chapter6"; +import { Ch7Content } from "../content/chapter7"; +import { Ch8Content } from "../content/chapter8"; +import BookmarkButton from "../../../components/BookmarkButton"; + + +import ChapterQuizInline from "../components/ChapterQuizInline"; +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { Righteous } from "next/font/google"; +import { moduleQuizzes } from "@/lib/quizData"; + +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +// Chapter data +const chapters = [ + { id: "ch0", title: "Course Outline", component: Ch0Content }, + + { + id: "ch1", + title: "Introduction to Operating Systems", + component: Ch1Content, + }, + + { + id: "ch2", + title: "Process Management", + component: Ch2Content, + }, + + { + id: "ch3", + title: "CPU Scheduling", + component: Ch3Content, + }, + + { + id: "ch4", + title: "Process Synchronization", + component: Ch4Content, + }, + + { + id: "ch5", + title: "Deadlocks", + component: Ch5Content, + }, + + { + id: "ch6", + title: "Memory Management", + component: Ch6Content, + }, + + { + id: "ch7", + title: "Paging and Segmentation", + component: Ch7Content, + }, + + { + id: "ch8", + title: "File Systems and I/O Management", + component: Ch8Content, + }, +]; + +type ChapterProps = { + params: { chapter: string }; +}; + +export default async function ChapterPage({ params }: { params: Promise<{ chapter: string }> }) { + const { chapter } = await params; + const currentIndex = chapters.findIndex( + (c) => c.id === chapter + ); + + const chapter = chapters[currentIndex]; + + if (!chapter) { + return ( +

+ Chapter not found +

+ ); + } + + const ChapterComponent = chapter.component; + + const prevChapter = + currentIndex > 0 + ? chapters[currentIndex - 1] + : null; + + const nextChapter = + currentIndex < chapters.length - 1 + ? chapters[currentIndex + 1] + : null; + + const chapterQuizSlugMap: Record = { + ch1: "os-intro", + ch2: "os-processes", + ch3: "os-scheduling", + ch4: "os-synchronization", + ch5: "os-deadlock", + ch6: "os-memory-management", + ch7: "os-paging-segmentation", + ch8: "os-file-io", + }; + + const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[chapter]); + + return ( +
+ {/* Content */} +
+

+ Operating System +

+ +
+

+ {chapter.title} +

+ +
+ + {/* Top Navigation */} +
+ {prevChapter ? ( + + + Previous + + ) : ( +
+ )} + + {nextChapter ? ( + + Next + + + ) : ( +
+ )} +
+ +
+ + + + {chapterQuiz ? ( +
+ +
+ ) : null} +
+ + {/* Bottom Navigation */} +
+ {prevChapter ? ( + + + {prevChapter.title} + + ) : ( +
+ )} + + {nextChapter ? ( + + {nextChapter.title} + + + ) : ( +
+ )} +
+
+ ); } \ No newline at end of file diff --git a/app/sem4/os/page.tsx b/app/sem4/os/page.tsx index ad6a870..d5ea1ef 100644 --- a/app/sem4/os/page.tsx +++ b/app/sem4/os/page.tsx @@ -1,5 +1,5 @@ -import { redirect } from "next/navigation"; - -export default function Page() { - redirect("/sem4/os/ch0"); -} +import { redirect } from "next/navigation"; + +export default function Page() { + redirect("/sem4/os/ch0"); +} diff --git a/app/sem5/cd/[chapter]/page.tsx b/app/sem5/cd/[chapter]/page.tsx index 97eb70f..e55d060 100644 --- a/app/sem5/cd/[chapter]/page.tsx +++ b/app/sem5/cd/[chapter]/page.tsx @@ -1,262 +1,262 @@ -import React from "react"; -import Link from "next/link"; -import { Metadata } from "next"; -import { Righteous } from "next/font/google"; -import { Ch0Content } from "../content/chapter0"; -import { Ch1Content } from "../content/chapter1"; -import { Ch2Content } from "../content/chapter2"; -import { Ch3Content } from "../content/chapter3"; -import { Ch4Content } from "../content/chapter4"; -import { LexicalAnalyzerGenContent } from "../content/ch4-lexical-analyzer-gen"; -import { Ch5Content } from "../content/chapter5"; -import { Ch6Content } from "../content/chapter6"; -import { NfaToDfaSubsetContent } from "../content/ch6-nfa-to-dfa-subset"; -import { DfaMinimizationContent } from "../content/ch6-dfa-minimization"; -import { DfaSolvedProblemContent } from "../content/ch6-dfa-solved-problem"; -import { Ch7Content } from "../content/chapter7"; -import { Ch8Content } from "../content/chapter8"; -import { Ll1SolvedProblemContent } from "../content/ch8-ll1-solved-problem"; -import { Ch9Content } from "../content/chapter9"; -import { Ch10Content } from "../content/chapter10"; -import { SlrSolvedProblemContent } from "../content/ch10-slr-solved-problem"; -import { Ch11Content } from "../content/chapter11"; -import { LalrSolvedProblemContent } from "../content/ch11-lalr-solved-problem"; -import { Ch12Content } from "../content/chapter12"; -import { Ch13Content } from "../content/chapter13"; -import { Ch14Content } from "../content/chapter14"; -import { ExprEvalExampleContent } from "../content/ch14-expr-eval-example"; -import { Ch15Content } from "../content/chapter15"; -import { Ch16Content } from "../content/chapter16"; -import { SdtPostfixTraceContent } from "../content/ch16-sdt-postfix-trace"; -import { Ch17Content } from "../content/chapter17"; -import { Ch18Content } from "../content/chapter18"; -import { Ch19Content } from "../content/chapter19"; -import { ScopeManagementContentExport } from "../content/ch19-scope-management"; -import { Ch20Content } from "../content/chapter20"; -import { ParameterPassingContentExport } from "../content/ch20-parameter-passing"; - -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; -import { chapters, SubTopic } from "../constants"; - -const righteous = Righteous({ - subsets: ["latin"], - weight: "400", - variable: "--font-righteous", -}); - -function findChapterOrSubtopic(chapterId: string) { - const chapter = chapters.find((c) => c.id === chapterId); - if (chapter) return { data: chapter, isSubTopic: false, parentChapter: null }; - - for (const ch of chapters) { - if (ch.subTopics) { - const sub = ch.subTopics.find( - (s) => s.id === chapterId && s.isPage - ) as (SubTopic & { isPage: true }) | undefined; - if (sub) return { data: sub, isSubTopic: true, parentChapter: ch }; - } - } - return { data: undefined, isSubTopic: false, parentChapter: null }; -} - -const chapterComponents: Record = { - ch0: Ch0Content, - ch1: Ch1Content, - ch2: Ch2Content, - ch3: Ch3Content, - ch4: Ch4Content, - "ch4-lexical-analyzer-gen": LexicalAnalyzerGenContent, - ch5: Ch5Content, - ch6: Ch6Content, - "ch6-nfa-to-dfa-subset": NfaToDfaSubsetContent, - "ch6-dfa-minimization": DfaMinimizationContent, - "ch6-dfa-solved-problem": DfaSolvedProblemContent, - ch7: Ch7Content, - ch8: Ch8Content, - "ch8-ll1-solved-problem": Ll1SolvedProblemContent, - ch9: Ch9Content, - ch10: Ch10Content, - "ch10-slr-solved-problem": SlrSolvedProblemContent, - ch11: Ch11Content, - "ch11-lalr-solved-problem": LalrSolvedProblemContent, - ch12: Ch12Content, - ch13: Ch13Content, - ch14: Ch14Content, - "ch14-expr-eval-example": ExprEvalExampleContent, - ch15: Ch15Content, - ch16: Ch16Content, - "ch16-sdt-postfix-trace": SdtPostfixTraceContent, - ch17: Ch17Content, - ch18: Ch18Content, - ch19: Ch19Content, - "ch19-scope-management": ScopeManagementContentExport, - ch20: Ch20Content, - "ch20-parameter-passing": ParameterPassingContentExport, - -}; - -type ChapterProps = { - params: Promise<{ chapter: string }>; -}; - -export async function generateMetadata({ - params, -}: ChapterProps): Promise { - const { chapter: chapterId } = await params; - const { data: chapterData } = findChapterOrSubtopic(chapterId); - - const title = chapterData - ? `${chapterData.title} | Compiler Design | openCSE` - : "Compiler Design | openCSE"; - - return { title }; -} - -export default async function ChapterPage({ params }: ChapterProps) { - const { chapter: chapterId } = await params; - const { data: chapterData, isSubTopic, parentChapter } = findChapterOrSubtopic( - chapterId - ); - - if (!chapterData) { - return ( -
-

Chapter not found

- - Return to Course Outline - -
- ); - } - - const ChapterComponent = chapterComponents[chapterData.id]; - let prevChapter = null; - let nextChapter = null; - - if (isSubTopic && parentChapter && parentChapter.subTopics) { - const pageSubTopics = parentChapter.subTopics.filter( - (s): s is SubTopic & { isPage: true } => !!s.isPage - ); - const subIndex = pageSubTopics.findIndex((s) => s.id === chapterId); - - if (subIndex > 0) { - prevChapter = pageSubTopics[subIndex - 1]; - } else { - prevChapter = { - id: parentChapter.id, - title: `Back to ${parentChapter.title}`, - }; - } - - if (subIndex < pageSubTopics.length - 1) { - nextChapter = pageSubTopics[subIndex + 1]; - } else { - const parentIndex = chapters.findIndex((c) => c.id === parentChapter.id); - if (parentIndex < chapters.length - 1) { - nextChapter = chapters[parentIndex + 1]; - } - } - } else { - const currentIndex = chapters.findIndex((c) => c.id === chapterId); - if (currentIndex > 0) { - const prevParent = chapters[currentIndex - 1]; - if (prevParent.subTopics && prevParent.subTopics.length > 0) { - const pageSubTopics = prevParent.subTopics.filter( - (s): s is SubTopic & { isPage: true } => !!s.isPage - ); - prevChapter = - pageSubTopics.length > 0 - ? pageSubTopics[pageSubTopics.length - 1] - : prevParent; - } else { - prevChapter = prevParent; - } - } - - const currentParent = chapters[currentIndex]; - if (currentParent.subTopics && currentParent.subTopics.length > 0) { - const pageSubTopics = currentParent.subTopics.filter( - (s): s is SubTopic & { isPage: true } => !!s.isPage - ); - nextChapter = pageSubTopics.length > 0 ? pageSubTopics[0] : null; - } else if (currentIndex < chapters.length - 1) { - nextChapter = chapters[currentIndex + 1]; - } - } - - return ( -
-
-

- Compiler Design -

- -

- {isSubTopic && parentChapter - ? `${parentChapter.title} / ${chapterData.title}` - : chapterData.title} -

- - {/* Navigation */} -
- {prevChapter ? ( - - Previous - - ) : ( -
- )} - - {nextChapter ? ( - - Next - - ) : ( -
- )} -
- -
- {ChapterComponent ? :

Content loading...

} -
- - {/* Bottom Navigation */} -
- {prevChapter ? ( - - {prevChapter.title} - - ) : ( -
- )} - - {nextChapter ? ( - - {nextChapter.title} - - ) : ( -
- )} -
-
- ); -} +import React from "react"; +import Link from "next/link"; +import { Metadata } from "next"; +import { Righteous } from "next/font/google"; +import { Ch0Content } from "../content/chapter0"; +import { Ch1Content } from "../content/chapter1"; +import { Ch2Content } from "../content/chapter2"; +import { Ch3Content } from "../content/chapter3"; +import { Ch4Content } from "../content/chapter4"; +import { LexicalAnalyzerGenContent } from "../content/ch4-lexical-analyzer-gen"; +import { Ch5Content } from "../content/chapter5"; +import { Ch6Content } from "../content/chapter6"; +import { NfaToDfaSubsetContent } from "../content/ch6-nfa-to-dfa-subset"; +import { DfaMinimizationContent } from "../content/ch6-dfa-minimization"; +import { DfaSolvedProblemContent } from "../content/ch6-dfa-solved-problem"; +import { Ch7Content } from "../content/chapter7"; +import { Ch8Content } from "../content/chapter8"; +import { Ll1SolvedProblemContent } from "../content/ch8-ll1-solved-problem"; +import { Ch9Content } from "../content/chapter9"; +import { Ch10Content } from "../content/chapter10"; +import { SlrSolvedProblemContent } from "../content/ch10-slr-solved-problem"; +import { Ch11Content } from "../content/chapter11"; +import { LalrSolvedProblemContent } from "../content/ch11-lalr-solved-problem"; +import { Ch12Content } from "../content/chapter12"; +import { Ch13Content } from "../content/chapter13"; +import { Ch14Content } from "../content/chapter14"; +import { ExprEvalExampleContent } from "../content/ch14-expr-eval-example"; +import { Ch15Content } from "../content/chapter15"; +import { Ch16Content } from "../content/chapter16"; +import { SdtPostfixTraceContent } from "../content/ch16-sdt-postfix-trace"; +import { Ch17Content } from "../content/chapter17"; +import { Ch18Content } from "../content/chapter18"; +import { Ch19Content } from "../content/chapter19"; +import { ScopeManagementContentExport } from "../content/ch19-scope-management"; +import { Ch20Content } from "../content/chapter20"; +import { ParameterPassingContentExport } from "../content/ch20-parameter-passing"; + +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { chapters, SubTopic } from "../constants"; + +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +function findChapterOrSubtopic(chapterId: string) { + const chapter = chapters.find((c) => c.id === chapterId); + if (chapter) return { data: chapter, isSubTopic: false, parentChapter: null }; + + for (const ch of chapters) { + if (ch.subTopics) { + const sub = ch.subTopics.find( + (s) => s.id === chapterId && s.isPage + ) as (SubTopic & { isPage: true }) | undefined; + if (sub) return { data: sub, isSubTopic: true, parentChapter: ch }; + } + } + return { data: undefined, isSubTopic: false, parentChapter: null }; +} + +const chapterComponents: Record = { + ch0: Ch0Content, + ch1: Ch1Content, + ch2: Ch2Content, + ch3: Ch3Content, + ch4: Ch4Content, + "ch4-lexical-analyzer-gen": LexicalAnalyzerGenContent, + ch5: Ch5Content, + ch6: Ch6Content, + "ch6-nfa-to-dfa-subset": NfaToDfaSubsetContent, + "ch6-dfa-minimization": DfaMinimizationContent, + "ch6-dfa-solved-problem": DfaSolvedProblemContent, + ch7: Ch7Content, + ch8: Ch8Content, + "ch8-ll1-solved-problem": Ll1SolvedProblemContent, + ch9: Ch9Content, + ch10: Ch10Content, + "ch10-slr-solved-problem": SlrSolvedProblemContent, + ch11: Ch11Content, + "ch11-lalr-solved-problem": LalrSolvedProblemContent, + ch12: Ch12Content, + ch13: Ch13Content, + ch14: Ch14Content, + "ch14-expr-eval-example": ExprEvalExampleContent, + ch15: Ch15Content, + ch16: Ch16Content, + "ch16-sdt-postfix-trace": SdtPostfixTraceContent, + ch17: Ch17Content, + ch18: Ch18Content, + ch19: Ch19Content, + "ch19-scope-management": ScopeManagementContentExport, + ch20: Ch20Content, + "ch20-parameter-passing": ParameterPassingContentExport, + +}; + +type ChapterProps = { + params: Promise<{ chapter: string }>; +}; + +export async function generateMetadata({ + params, +}: ChapterProps): Promise { + const { chapter: chapterId } = await params; + const { data: chapterData } = findChapterOrSubtopic(chapterId); + + const title = chapterData + ? `${chapterData.title} | Compiler Design | openCSE` + : "Compiler Design | openCSE"; + + return { title }; +} + +export default async function ChapterPage({ params }: ChapterProps) { + const { chapter: chapterId } = await params; + const { data: chapterData, isSubTopic, parentChapter } = findChapterOrSubtopic( + chapterId + ); + + if (!chapterData) { + return ( +
+

Chapter not found

+ + Return to Course Outline + +
+ ); + } + + const ChapterComponent = chapterComponents[chapterData.id]; + let prevChapter = null; + let nextChapter = null; + + if (isSubTopic && parentChapter && parentChapter.subTopics) { + const pageSubTopics = parentChapter.subTopics.filter( + (s): s is SubTopic & { isPage: true } => !!s.isPage + ); + const subIndex = pageSubTopics.findIndex((s) => s.id === chapterId); + + if (subIndex > 0) { + prevChapter = pageSubTopics[subIndex - 1]; + } else { + prevChapter = { + id: parentChapter.id, + title: `Back to ${parentChapter.title}`, + }; + } + + if (subIndex < pageSubTopics.length - 1) { + nextChapter = pageSubTopics[subIndex + 1]; + } else { + const parentIndex = chapters.findIndex((c) => c.id === parentChapter.id); + if (parentIndex < chapters.length - 1) { + nextChapter = chapters[parentIndex + 1]; + } + } + } else { + const currentIndex = chapters.findIndex((c) => c.id === chapterId); + if (currentIndex > 0) { + const prevParent = chapters[currentIndex - 1]; + if (prevParent.subTopics && prevParent.subTopics.length > 0) { + const pageSubTopics = prevParent.subTopics.filter( + (s): s is SubTopic & { isPage: true } => !!s.isPage + ); + prevChapter = + pageSubTopics.length > 0 + ? pageSubTopics[pageSubTopics.length - 1] + : prevParent; + } else { + prevChapter = prevParent; + } + } + + const currentParent = chapters[currentIndex]; + if (currentParent.subTopics && currentParent.subTopics.length > 0) { + const pageSubTopics = currentParent.subTopics.filter( + (s): s is SubTopic & { isPage: true } => !!s.isPage + ); + nextChapter = pageSubTopics.length > 0 ? pageSubTopics[0] : null; + } else if (currentIndex < chapters.length - 1) { + nextChapter = chapters[currentIndex + 1]; + } + } + + return ( +
+
+

+ Compiler Design +

+ +

+ {isSubTopic && parentChapter + ? `${parentChapter.title} / ${chapterData.title}` + : chapterData.title} +

+ + {/* Navigation */} +
+ {prevChapter ? ( + + Previous + + ) : ( +
+ )} + + {nextChapter ? ( + + Next + + ) : ( +
+ )} +
+ +
+ {ChapterComponent ? :

Content loading...

} +
+ + {/* Bottom Navigation */} +
+ {prevChapter ? ( + + {prevChapter.title} + + ) : ( +
+ )} + + {nextChapter ? ( + + {nextChapter.title} + + ) : ( +
+ )} +
+
+ ); +} diff --git a/app/sem5/cle/[chapter]/page.tsx b/app/sem5/cle/[chapter]/page.tsx index efac1a9..2a1f020 100644 --- a/app/sem5/cle/[chapter]/page.tsx +++ b/app/sem5/cle/[chapter]/page.tsx @@ -1,188 +1,188 @@ -import Link from "next/link"; -import { Metadata } from "next"; -import { Righteous } from "next/font/google"; -import { Ch0Content } from "../content/chapter0"; // ← only ch0 for now -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; -import { chapters, Chapter, SubTopic } from "../constants"; // ← cle constants - -function findChapterOrSubtopic(chapterId: string) { - const chapter = chapters.find((c) => c.id === chapterId); - if (chapter) return { data: chapter, isSubTopic: false, parentChapter: null }; - - for (const ch of chapters) { - if (ch.subTopics) { - const sub = ch.subTopics.find( - (s) => s.id === chapterId && s.isPage - ) as (SubTopic & { isPage: true }) | undefined; - if (sub) return { data: sub, isSubTopic: true, parentChapter: ch }; - } - } - return { data: undefined, isSubTopic: false, parentChapter: null }; -} - -const righteous = Righteous({ - subsets: ["latin"], - weight: "400", - variable: "--font-righteous", -}); - -// Only ch0 is available for now — more chapters added in future PRs -const chapterComponents: Record = { - ch0: Ch0Content, -}; - -type ChapterProps = { - params: Promise<{ chapter: string }>; -}; - -export async function generateMetadata({ - params, -}: ChapterProps): Promise { - const { chapter: chapterId } = await params; - const { data: chapterData } = findChapterOrSubtopic(chapterId); - - const title = chapterData - ? `${chapterData.title} | Cyber Laws and Ethics | openCSE` // ← subject name - : "Cyber Laws and Ethics | openCSE"; - - return { title }; -} - -export default async function ChapterPage({ params }: ChapterProps) { - const { chapter: chapterId } = await params; - - const { - data: chapterData, - isSubTopic, - parentChapter, - } = findChapterOrSubtopic(chapterId); - - if (!chapterData) { - return ( -
-

Chapter not found

- - Return to Course Outline - -
- ); - } - - const ChapterComponent = chapterComponents[chapterData.id]; - let prevChapter = null; - let nextChapter = null; - - if (isSubTopic && parentChapter && parentChapter.subTopics) { - const pageSubTopics = parentChapter.subTopics.filter( - (s): s is SubTopic & { isPage: true } => !!s.isPage - ); - const subIndex = pageSubTopics.findIndex((s) => s.id === chapterId); - - if (subIndex > 0) { - prevChapter = pageSubTopics[subIndex - 1]; - } else { - prevChapter = { - id: parentChapter.id, - title: `Back to ${parentChapter.title}`, - }; - } - - if (subIndex < pageSubTopics.length - 1) { - nextChapter = pageSubTopics[subIndex + 1]; - } else { - const parentIndex = chapters.findIndex((c) => c.id === parentChapter.id); - if (parentIndex < chapters.length - 1) { - nextChapter = chapters[parentIndex + 1]; - } - } - } else { - const currentIndex = chapters.findIndex((c) => c.id === chapterId); - prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; - nextChapter = - currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; - } - - return ( -
-
-

- Cyber Laws and Ethics {/* ← subject name */} -

- -

- {isSubTopic && parentChapter - ? `${parentChapter.title} / ${chapterData.title}` - : chapterData.title} -

- -
- {prevChapter ? ( - - Previous - - ) : ( -
- )} - {nextChapter ? ( - - Next - - ) : ( -
- )} -
- -
- - {/* Show content if available, else show coming soon message */} - {ChapterComponent ? ( - - ) : ( -
-

Coming Soon

-

- This chapter is under development. Check back soon! -

-
- )} -
- -
- {prevChapter ? ( - - {prevChapter.title} - - ) : ( -
- )} - {nextChapter ? ( - - {nextChapter.title} {" "} - - - ) : ( -
- )} -
-
- ); -} +import Link from "next/link"; +import { Metadata } from "next"; +import { Righteous } from "next/font/google"; +import { Ch0Content } from "../content/chapter0"; // ← only ch0 for now +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { chapters, Chapter, SubTopic } from "../constants"; // ← cle constants + +function findChapterOrSubtopic(chapterId: string) { + const chapter = chapters.find((c) => c.id === chapterId); + if (chapter) return { data: chapter, isSubTopic: false, parentChapter: null }; + + for (const ch of chapters) { + if (ch.subTopics) { + const sub = ch.subTopics.find( + (s) => s.id === chapterId && s.isPage + ) as (SubTopic & { isPage: true }) | undefined; + if (sub) return { data: sub, isSubTopic: true, parentChapter: ch }; + } + } + return { data: undefined, isSubTopic: false, parentChapter: null }; +} + +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +// Only ch0 is available for now — more chapters added in future PRs +const chapterComponents: Record = { + ch0: Ch0Content, +}; + +type ChapterProps = { + params: Promise<{ chapter: string }>; +}; + +export async function generateMetadata({ + params, +}: ChapterProps): Promise { + const { chapter: chapterId } = await params; + const { data: chapterData } = findChapterOrSubtopic(chapterId); + + const title = chapterData + ? `${chapterData.title} | Cyber Laws and Ethics | openCSE` // ← subject name + : "Cyber Laws and Ethics | openCSE"; + + return { title }; +} + +export default async function ChapterPage({ params }: ChapterProps) { + const { chapter: chapterId } = await params; + + const { + data: chapterData, + isSubTopic, + parentChapter, + } = findChapterOrSubtopic(chapterId); + + if (!chapterData) { + return ( +
+

Chapter not found

+ + Return to Course Outline + +
+ ); + } + + const ChapterComponent = chapterComponents[chapterData.id]; + let prevChapter = null; + let nextChapter = null; + + if (isSubTopic && parentChapter && parentChapter.subTopics) { + const pageSubTopics = parentChapter.subTopics.filter( + (s): s is SubTopic & { isPage: true } => !!s.isPage + ); + const subIndex = pageSubTopics.findIndex((s) => s.id === chapterId); + + if (subIndex > 0) { + prevChapter = pageSubTopics[subIndex - 1]; + } else { + prevChapter = { + id: parentChapter.id, + title: `Back to ${parentChapter.title}`, + }; + } + + if (subIndex < pageSubTopics.length - 1) { + nextChapter = pageSubTopics[subIndex + 1]; + } else { + const parentIndex = chapters.findIndex((c) => c.id === parentChapter.id); + if (parentIndex < chapters.length - 1) { + nextChapter = chapters[parentIndex + 1]; + } + } + } else { + const currentIndex = chapters.findIndex((c) => c.id === chapterId); + prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; + nextChapter = + currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + } + + return ( +
+
+

+ Cyber Laws and Ethics {/* ← subject name */} +

+ +

+ {isSubTopic && parentChapter + ? `${parentChapter.title} / ${chapterData.title}` + : chapterData.title} +

+ +
+ {prevChapter ? ( + + Previous + + ) : ( +
+ )} + {nextChapter ? ( + + Next + + ) : ( +
+ )} +
+ +
+ + {/* Show content if available, else show coming soon message */} + {ChapterComponent ? ( + + ) : ( +
+

Coming Soon

+

+ This chapter is under development. Check back soon! +

+
+ )} +
+ +
+ {prevChapter ? ( + + {prevChapter.title} + + ) : ( +
+ )} + {nextChapter ? ( + + {nextChapter.title} {" "} + + + ) : ( +
+ )} +
+
+ ); +} diff --git a/app/sem6/ml/[chapter]/page.tsx b/app/sem6/ml/[chapter]/page.tsx index fcbb1cb..95a7c7a 100644 --- a/app/sem6/ml/[chapter]/page.tsx +++ b/app/sem6/ml/[chapter]/page.tsx @@ -1,276 +1,276 @@ -import Link from "next/link"; -import { Metadata } from 'next'; -import { Righteous } from "next/font/google"; -import { Ch0Content } from "../content/chapter0"; -import { Ch1Content } from "../content/chapter1"; -import { Ch2Content } from "../content/chapter2"; -import { DataPreprocessingContent } from "../content/data-preprocessing"; -import { DimensionalityReductionContent } from "../content/dimensionality-reduction"; -import { FeatureSelectionContent } from "../content/feature-selection"; -import { RegressionModelsContent } from "../content/regression-models"; -import { PCADeepDiveContent } from "../content/pca-deep-dive"; -import { AdvancedDimReductionContent } from "../content/advanced-dim-reduction"; -import { RegressionEvaluationContent } from "../content/regression-evaluation"; -import { MulticollinearityContent } from "../content/multicollinearity"; -import { Chapter3Content } from "../content/chapter3"; -import { IntroClassificationContent } from "../content/intro-classification"; -import { LogisticRegressionContent } from "../content/logistic-regression"; -import { KnnContent } from "../content/knn"; -import { NaiveBayesContent } from "../content/naive-bayes"; -import { DecisionTreesContent } from "../content/decision-trees"; -import { SvmContent } from "../content/svm"; -import { RecommendationSystemsContent } from "../content/recommendation-systems"; -import { Chapter4Content } from "../content/chapter4"; -import { IntroUnsupervisedContent } from "../content/intro-unsupervised"; -import { KMeansContent } from "../content/kmeans"; -import { KMedoidsContent } from "../content/kmedoids"; -import { HierarchicalContent } from "../content/hierarchical"; -import { AprioriContent } from "../content/apriori"; -import { AnomalyDetectionContent } from "../content/anomaly-detection"; -import { Chapter5Content } from "../content/chapter5"; -import { EnsembleLearningContent } from "../content/ensemble-learning"; -import { ImageRecognitionContent } from "../content/image-recognition"; -import { SpeechRecognitionContent } from "../content/speech-recognition"; -import { PredictionRecommendationContent } from "../content/prediction-recommendation"; -import { SpamMalwareContent } from "../content/spam-malware"; -import { VirtualAssistantContent } from "../content/virtual-assistant"; -import { FraudDetectionContent } from "../content/fraud-detection"; -import { Chapter6Content } from "../content/chapter6"; -import { DeepLearningContent } from "../content/deep-learning"; -import { ReinforcementLearningContent } from "../content/reinforcement-learning"; -import { NlpBasicsContent } from "../content/nlp-basics"; -import { MlopsDeploymentContent } from "../content/mlops-deployment"; -import { XaiEthicsContent } from "../content/xai-ethics"; -import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; -import { chapters, Chapter, SubTopic } from "../constants"; - -import BookmarkButton from "../../../components/BookmarkButton"; - -import { moduleQuizzes } from "@/lib/quizData"; -import ChapterQuizInline from "../components/ChapterQuizInline"; - -function findChapterOrSubtopic(chapterId: string) { - const chapter = chapters.find((c) => c.id === chapterId); - if (chapter) return { data: chapter, isSubTopic: false, parentChapter: null }; - - for (const ch of chapters) { - if (ch.subTopics) { - const sub = ch.subTopics.find((s) => s.id === chapterId && s.isPage) as (SubTopic & { isPage: true }) | undefined; - if (sub) return { data: sub, isSubTopic: true, parentChapter: ch }; - } - } - return { data: undefined, isSubTopic: false, parentChapter: null }; -} - -const righteous = Righteous({ - subsets: ["latin"], - weight: "400", - variable: "--font-righteous", -}); - -// Map components to chapter IDs -const chapterComponents: Record = { - ch0: Ch0Content, - ch1: Ch1Content, - ch2: Ch2Content, - "ch2-data-preprocessing": DataPreprocessingContent, - "ch2-dimensionality-reduction": DimensionalityReductionContent, - "ch2-feature-selection": FeatureSelectionContent, - "ch2-regression-models": RegressionModelsContent, - "ch2-pca-deep-dive": PCADeepDiveContent, - "ch2-advanced-dim-reduction": AdvancedDimReductionContent, - "ch2-regression-evaluation": RegressionEvaluationContent, - "ch2-multicollinearity": MulticollinearityContent, - "ch3": Chapter3Content, - "ch3-intro": IntroClassificationContent, - "ch3-logistic-regression": LogisticRegressionContent, - "ch3-knn": KnnContent, - "ch3-naive-bayes": NaiveBayesContent, - "ch3-decision-trees": DecisionTreesContent, - "ch3-svm": SvmContent, - "ch3-recommendation-systems": RecommendationSystemsContent, - "ch4": Chapter4Content, - "ch4-intro": IntroUnsupervisedContent, - "ch4-kmeans": KMeansContent, - "ch4-kmedoids": KMedoidsContent, - "ch4-hierarchical": HierarchicalContent, - "ch4-apriori": AprioriContent, - "ch4-anomaly-detection": AnomalyDetectionContent, - "ch5": Chapter5Content, - "ch5-ensemble": EnsembleLearningContent, - "ch5-image-recognition": ImageRecognitionContent, - "ch5-speech-recognition": SpeechRecognitionContent, - "ch5-prediction-recommendation": PredictionRecommendationContent, - "ch5-spam-malware": SpamMalwareContent, - "ch5-virtual-assistant": VirtualAssistantContent, - "ch5-fraud-detection": FraudDetectionContent, - "ch6": Chapter6Content, - "ch6-deep-learning": DeepLearningContent, - "ch6-reinforcement": ReinforcementLearningContent, - "ch6-nlp": NlpBasicsContent, - "ch6-mlops": MlopsDeploymentContent, - "ch6-xai": XaiEthicsContent, -}; - -type ChapterProps = { - params: Promise<{ chapter: string }>; -}; - -// Generate dynamic SEO metadata -export async function generateMetadata({ params }: ChapterProps): Promise { - const { chapter: chapterId } = await params; - const { data: chapterData } = findChapterOrSubtopic(chapterId); - - const title = chapterData - ? `${chapterData.title} | Machine Learning | openCSE` - : "Machine Learning | openCSE"; - - return { title }; -} - -export default async function ChapterPage({ params }: ChapterProps) { - const { chapter: chapterId } = await params; - - const { data: chapterData, isSubTopic, parentChapter } = findChapterOrSubtopic(chapterId); - - if (!chapterData) { - return ( -
-

Chapter not found

- - Return to Course Outline - -
- ); - } - - const ChapterComponent = chapterComponents[chapterData.id]; - let prevChapter = null; - let nextChapter = null; - - // UX Fix: Better pagination linking siblings - if (isSubTopic && parentChapter && parentChapter.subTopics) { - const pageSubTopics = parentChapter.subTopics.filter((s): s is SubTopic & { isPage: true } => !!s.isPage); - const subIndex = pageSubTopics.findIndex(s => s.id === chapterId); - - if (subIndex > 0) { - prevChapter = pageSubTopics[subIndex - 1]; - } else { - prevChapter = { id: parentChapter.id, title: `Back to ${parentChapter.title}` }; - } - - if (subIndex < pageSubTopics.length - 1) { - nextChapter = pageSubTopics[subIndex + 1]; - } else { - // Last subtopic -> link to next main chapter if available - const parentIndex = chapters.findIndex(c => c.id === parentChapter.id); - if (parentIndex < chapters.length - 1) { - nextChapter = chapters[parentIndex + 1]; - } - } - } else { - // Top-level chapter - const currentIndex = chapters.findIndex((c) => c.id === chapterId); - prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; - nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; - } - - const chapterQuizSlugMap: Record = { - "ch1": "ml-intro", - "ch2-data-preprocessing": "ml-data-preprocessing", - "ch2-dimensionality-reduction": "ml-dimensionality-reduction", - "ch2-pca-deep-dive": "ml-pca-deep-dive", - "ch2-advanced-dim-reduction": "ml-advanced-dim-reduction", - "ch2-feature-selection": "ml-feature-selection", - "ch2-regression-models": "ml-regression-models", - "ch2-regression-evaluation": "ml-regression-evaluation", - "ch2-multicollinearity": "ml-multicollinearity", - }; - const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[chapterId]); - - return ( -
-
-

- Machine Learning -

- -
-

- {isSubTopic && parentChapter ? `${parentChapter.title} / ${chapterData.title}` : chapterData.title} -

- -
- - - - {/* Navigation */} -
- {prevChapter ? ( - - Previous - - ) : ( -
- )} - - {nextChapter ? ( - - Next - - ) : ( -
- )} -
- -
- - - {chapterQuiz ? ( -
- -
- ) : null} -
- - {/* Bottom Navigation */} -
- {prevChapter ? ( - - {prevChapter.title} - - ) : ( -
- )} - - {nextChapter ? ( - - {nextChapter.title}{" "} - - - ) : ( -
- )} -
-
- ); -} +import Link from "next/link"; +import { Metadata } from 'next'; +import { Righteous } from "next/font/google"; +import { Ch0Content } from "../content/chapter0"; +import { Ch1Content } from "../content/chapter1"; +import { Ch2Content } from "../content/chapter2"; +import { DataPreprocessingContent } from "../content/data-preprocessing"; +import { DimensionalityReductionContent } from "../content/dimensionality-reduction"; +import { FeatureSelectionContent } from "../content/feature-selection"; +import { RegressionModelsContent } from "../content/regression-models"; +import { PCADeepDiveContent } from "../content/pca-deep-dive"; +import { AdvancedDimReductionContent } from "../content/advanced-dim-reduction"; +import { RegressionEvaluationContent } from "../content/regression-evaluation"; +import { MulticollinearityContent } from "../content/multicollinearity"; +import { Chapter3Content } from "../content/chapter3"; +import { IntroClassificationContent } from "../content/intro-classification"; +import { LogisticRegressionContent } from "../content/logistic-regression"; +import { KnnContent } from "../content/knn"; +import { NaiveBayesContent } from "../content/naive-bayes"; +import { DecisionTreesContent } from "../content/decision-trees"; +import { SvmContent } from "../content/svm"; +import { RecommendationSystemsContent } from "../content/recommendation-systems"; +import { Chapter4Content } from "../content/chapter4"; +import { IntroUnsupervisedContent } from "../content/intro-unsupervised"; +import { KMeansContent } from "../content/kmeans"; +import { KMedoidsContent } from "../content/kmedoids"; +import { HierarchicalContent } from "../content/hierarchical"; +import { AprioriContent } from "../content/apriori"; +import { AnomalyDetectionContent } from "../content/anomaly-detection"; +import { Chapter5Content } from "../content/chapter5"; +import { EnsembleLearningContent } from "../content/ensemble-learning"; +import { ImageRecognitionContent } from "../content/image-recognition"; +import { SpeechRecognitionContent } from "../content/speech-recognition"; +import { PredictionRecommendationContent } from "../content/prediction-recommendation"; +import { SpamMalwareContent } from "../content/spam-malware"; +import { VirtualAssistantContent } from "../content/virtual-assistant"; +import { FraudDetectionContent } from "../content/fraud-detection"; +import { Chapter6Content } from "../content/chapter6"; +import { DeepLearningContent } from "../content/deep-learning"; +import { ReinforcementLearningContent } from "../content/reinforcement-learning"; +import { NlpBasicsContent } from "../content/nlp-basics"; +import { MlopsDeploymentContent } from "../content/mlops-deployment"; +import { XaiEthicsContent } from "../content/xai-ethics"; +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { chapters, Chapter, SubTopic } from "../constants"; + +import BookmarkButton from "../../../components/BookmarkButton"; + +import { moduleQuizzes } from "@/lib/quizData"; +import ChapterQuizInline from "../components/ChapterQuizInline"; + +function findChapterOrSubtopic(chapterId: string) { + const chapter = chapters.find((c) => c.id === chapterId); + if (chapter) return { data: chapter, isSubTopic: false, parentChapter: null }; + + for (const ch of chapters) { + if (ch.subTopics) { + const sub = ch.subTopics.find((s) => s.id === chapterId && s.isPage) as (SubTopic & { isPage: true }) | undefined; + if (sub) return { data: sub, isSubTopic: true, parentChapter: ch }; + } + } + return { data: undefined, isSubTopic: false, parentChapter: null }; +} + +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +// Map components to chapter IDs +const chapterComponents: Record = { + ch0: Ch0Content, + ch1: Ch1Content, + ch2: Ch2Content, + "ch2-data-preprocessing": DataPreprocessingContent, + "ch2-dimensionality-reduction": DimensionalityReductionContent, + "ch2-feature-selection": FeatureSelectionContent, + "ch2-regression-models": RegressionModelsContent, + "ch2-pca-deep-dive": PCADeepDiveContent, + "ch2-advanced-dim-reduction": AdvancedDimReductionContent, + "ch2-regression-evaluation": RegressionEvaluationContent, + "ch2-multicollinearity": MulticollinearityContent, + "ch3": Chapter3Content, + "ch3-intro": IntroClassificationContent, + "ch3-logistic-regression": LogisticRegressionContent, + "ch3-knn": KnnContent, + "ch3-naive-bayes": NaiveBayesContent, + "ch3-decision-trees": DecisionTreesContent, + "ch3-svm": SvmContent, + "ch3-recommendation-systems": RecommendationSystemsContent, + "ch4": Chapter4Content, + "ch4-intro": IntroUnsupervisedContent, + "ch4-kmeans": KMeansContent, + "ch4-kmedoids": KMedoidsContent, + "ch4-hierarchical": HierarchicalContent, + "ch4-apriori": AprioriContent, + "ch4-anomaly-detection": AnomalyDetectionContent, + "ch5": Chapter5Content, + "ch5-ensemble": EnsembleLearningContent, + "ch5-image-recognition": ImageRecognitionContent, + "ch5-speech-recognition": SpeechRecognitionContent, + "ch5-prediction-recommendation": PredictionRecommendationContent, + "ch5-spam-malware": SpamMalwareContent, + "ch5-virtual-assistant": VirtualAssistantContent, + "ch5-fraud-detection": FraudDetectionContent, + "ch6": Chapter6Content, + "ch6-deep-learning": DeepLearningContent, + "ch6-reinforcement": ReinforcementLearningContent, + "ch6-nlp": NlpBasicsContent, + "ch6-mlops": MlopsDeploymentContent, + "ch6-xai": XaiEthicsContent, +}; + +type ChapterProps = { + params: Promise<{ chapter: string }>; +}; + +// Generate dynamic SEO metadata +export async function generateMetadata({ params }: ChapterProps): Promise { + const { chapter: chapterId } = await params; + const { data: chapterData } = findChapterOrSubtopic(chapterId); + + const title = chapterData + ? `${chapterData.title} | Machine Learning | openCSE` + : "Machine Learning | openCSE"; + + return { title }; +} + +export default async function ChapterPage({ params }: ChapterProps) { + const { chapter: chapterId } = await params; + + const { data: chapterData, isSubTopic, parentChapter } = findChapterOrSubtopic(chapterId); + + if (!chapterData) { + return ( +
+

Chapter not found

+ + Return to Course Outline + +
+ ); + } + + const ChapterComponent = chapterComponents[chapterData.id]; + let prevChapter = null; + let nextChapter = null; + + // UX Fix: Better pagination linking siblings + if (isSubTopic && parentChapter && parentChapter.subTopics) { + const pageSubTopics = parentChapter.subTopics.filter((s): s is SubTopic & { isPage: true } => !!s.isPage); + const subIndex = pageSubTopics.findIndex(s => s.id === chapterId); + + if (subIndex > 0) { + prevChapter = pageSubTopics[subIndex - 1]; + } else { + prevChapter = { id: parentChapter.id, title: `Back to ${parentChapter.title}` }; + } + + if (subIndex < pageSubTopics.length - 1) { + nextChapter = pageSubTopics[subIndex + 1]; + } else { + // Last subtopic -> link to next main chapter if available + const parentIndex = chapters.findIndex(c => c.id === parentChapter.id); + if (parentIndex < chapters.length - 1) { + nextChapter = chapters[parentIndex + 1]; + } + } + } else { + // Top-level chapter + const currentIndex = chapters.findIndex((c) => c.id === chapterId); + prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; + nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + } + + const chapterQuizSlugMap: Record = { + "ch1": "ml-intro", + "ch2-data-preprocessing": "ml-data-preprocessing", + "ch2-dimensionality-reduction": "ml-dimensionality-reduction", + "ch2-pca-deep-dive": "ml-pca-deep-dive", + "ch2-advanced-dim-reduction": "ml-advanced-dim-reduction", + "ch2-feature-selection": "ml-feature-selection", + "ch2-regression-models": "ml-regression-models", + "ch2-regression-evaluation": "ml-regression-evaluation", + "ch2-multicollinearity": "ml-multicollinearity", + }; + const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[chapterId]); + + return ( +
+
+

+ Machine Learning +

+ +
+

+ {isSubTopic && parentChapter ? `${parentChapter.title} / ${chapterData.title}` : chapterData.title} +

+ +
+ + + + {/* Navigation */} +
+ {prevChapter ? ( + + Previous + + ) : ( +
+ )} + + {nextChapter ? ( + + Next + + ) : ( +
+ )} +
+ +
+ + + {chapterQuiz ? ( +
+ +
+ ) : null} +
+ + {/* Bottom Navigation */} +
+ {prevChapter ? ( + + {prevChapter.title} + + ) : ( +
+ )} + + {nextChapter ? ( + + {nextChapter.title}{" "} + + + ) : ( +
+ )} +
+
+ ); +}