diff --git a/app/components/subjects.tsx b/app/components/subjects.tsx index 724b848..96adf49 100644 --- a/app/components/subjects.tsx +++ b/app/components/subjects.tsx @@ -4,6 +4,7 @@ import Link from "next/link"; const subjects = { "Semester-1": [ "Basic Electrical and Electronics", + "Basics of Mechanical Engineering", "C Programming", "Engineering Mathematics-1", "Engineering Physics", @@ -76,6 +77,7 @@ const subjectCodes: Record = { "Engineering Physics": "ep", "Engineering Graphics & Design": "egd", "English Communication": "ec", + "Basics of Mechanical Engineering": "bme", "Digital Electronics & Logic Circuits": "delc", "OOPs with Java": "oops", @@ -125,7 +127,7 @@ const subjectCodes: Record = { }; // Available subjects -const available = ["ep", "c", "em1", "em2", "oops", "dsc", "coa", "os", "ml", "dops", "cd", "cle","ec"]; +const available = ["ep", "c", "em1", "em2", "oops", "dsc", "coa", "os", "ml", "dops", "cd", "cle","ec","bme"]; export default function SubjectsSection() { return ( diff --git a/app/sem1/bme/[chapter]/page.tsx b/app/sem1/bme/[chapter]/page.tsx new file mode 100644 index 0000000..7b962b8 --- /dev/null +++ b/app/sem1/bme/[chapter]/page.tsx @@ -0,0 +1,186 @@ +import Link from "next/link"; +import { Metadata } from "next"; +import { Righteous } from "next/font/google"; +import { Ch0Content } from "../content/chapter0"; +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { chapters, Chapter, SubTopic } from "../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", +}); + +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} | Basics of Mechanical Engineering | openCSE` + : "Basics of Mechanical Engineering | 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 ( +
+
+

+ Basics of Mechanical Engineering +

+ +

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

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

Coming Soon

+

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

+
+ )} +
+ +
+ {prevChapter ? ( + + {prevChapter.title} + + ) : ( +
+ )} + {nextChapter ? ( + + {nextChapter.title}{" "} + + + ) : ( +
+ )} +
+
+ ); +} \ No newline at end of file diff --git a/app/sem1/bme/components/sidebar.tsx b/app/sem1/bme/components/sidebar.tsx new file mode 100644 index 0000000..3fa2f89 --- /dev/null +++ b/app/sem1/bme/components/sidebar.tsx @@ -0,0 +1,110 @@ +"use client"; +import { Righteous } from "next/font/google"; +import Link from "next/link"; +import { usePathname } from "next/navigation"; +import { useState, useEffect } from "react"; +import { chapters } from "../constants"; + +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +export default function Sidebar() { + const pathname = usePathname(); + const [open, setOpen] = useState(false); + + useEffect(() => { + if (window.innerWidth >= 768) { + setOpen(true); + } + }, []); + + return ( + <> +
setOpen(false)} + /> + +
+ + + +
+ + ); +} \ No newline at end of file diff --git a/app/sem1/bme/constants.ts b/app/sem1/bme/constants.ts new file mode 100644 index 0000000..506043b --- /dev/null +++ b/app/sem1/bme/constants.ts @@ -0,0 +1,22 @@ +export type SubTopic = + | { id: string; title: string; isPage: true } + | { id: string; title: string; isPage?: false }; + +export type Chapter = { + id: string; + title: string; + subTopics?: SubTopic[]; +}; + +export const chapters: Chapter[] = [ + { id: "ch0", title: "Course Outline" }, + { id: "ch1", title: "Thermodynamics" }, + { id: "ch2", title: "Steam Properties and Steam Tables" }, + { id: "ch3", title: "Otto, Diesel and Carnot Cycles" }, + { id: "ch4", title: "IC Engines" }, + { id: "ch5", title: "Engineering Materials" }, + { id: "ch6", title: "Manufacturing Processes" }, + { id: "ch7", title: "Stress-Strain Concepts" }, + { id: "ch8", title: "SFD and BMD" }, + { id: "ch9", title: "Bending and Torsion" }, +]; \ No newline at end of file diff --git a/app/sem1/bme/content/chapter0.tsx b/app/sem1/bme/content/chapter0.tsx new file mode 100644 index 0000000..39d3f10 --- /dev/null +++ b/app/sem1/bme/content/chapter0.tsx @@ -0,0 +1,39 @@ +export function Ch0Content() { + return ( +
+

+ Basics of Mechanical Engineering (BME) is a core first-year subject that + bridges fundamental mechanical concepts with their engineering applications. + This course covers thermodynamics, steam properties, engine cycles, IC engines, + engineering materials, manufacturing processes, and solid mechanics — all + explained in a beginner-friendly, exam-oriented style. +

+ +
+

Chapters at a Glance

+
    +
  • Ch 1 — Thermodynamics: Laws, systems, heat & work
  • +
  • Ch 2 — Steam Properties & Steam Tables
  • +
  • Ch 3 — Otto, Diesel & Carnot Cycles with P-V diagrams
  • +
  • Ch 4 — IC Engines: 2-stroke, 4-stroke, CRDI, MPFI
  • +
  • Ch 5 — Engineering Materials: metals, alloys, composites
  • +
  • Ch 6 — Manufacturing Processes: casting, welding, machining
  • +
  • Ch 7 — Stress-Strain, SFD, BMD, Bending & Torsion equations
  • +
+
+ +
+

Key Formulas Quick Reference

+
    +
  • Carnot Efficiency: η = 1 − T₂/T₁
  • +
  • Otto Cycle Efficiency: η = 1 − 1/r^(γ−1)
  • +
  • Diesel Cycle Efficiency: η = 1 − (1/r^(γ−1)) × [(ρᵞ−1) / γ(ρ−1)]
  • +
  • Dryness Fraction: x = m_s / (m_s + m_w)
  • +
  • Hooke's Law: σ = E × ε
  • +
  • Bending Equation: M/I = σ/y = E/R
  • +
  • Torsion Equation: T/J = τ/r = Gθ/L
  • +
+
+
+ ); +} \ No newline at end of file diff --git a/app/sem1/bme/layout.tsx b/app/sem1/bme/layout.tsx new file mode 100644 index 0000000..55e5244 --- /dev/null +++ b/app/sem1/bme/layout.tsx @@ -0,0 +1,18 @@ +import Navbar from "@/app/components/navbar"; +import Sidebar from "./components/sidebar"; + +export default function BMELayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( +
+ +
+ +
{children}
+
+
+ ); +} \ No newline at end of file