11import { notFound } from 'next/navigation'
22import { CustomMDX } from '@/components/mdx'
33import { getCourseModules } from '../utils'
4+ import { Button } from '@/components/button'
5+ import Link from 'next/link'
46
57const baseUrl = process . env . NEXT_PUBLIC_SITE_URL || 'http://localhost:3000'
68
@@ -55,12 +57,18 @@ export async function generateMetadata({ params }: { params: Promise<{ slug: str
5557
5658export default async function CourseModule ( { params } : { params : Promise < { slug : string } > } ) {
5759 const { slug } = await params
58- const courseModule = getCourseModules ( ) . find ( ( module ) => module . slug === slug )
60+ const allModules = getCourseModules ( )
61+ const courseModule = allModules . find ( ( module ) => module . slug === slug )
5962
6063 if ( ! courseModule ) {
6164 notFound ( )
6265 }
6366
67+ // Find current module index
68+ const currentIndex = allModules . findIndex ( ( module ) => module . slug === slug )
69+ const prevModule = currentIndex > 0 ? allModules [ currentIndex - 1 ] : null
70+ const nextModule = currentIndex < allModules . length - 1 ? allModules [ currentIndex + 1 ] : null
71+
6472 return (
6573 < section className = "items-center justify-center" >
6674 < script
@@ -85,6 +93,8 @@ export default async function CourseModule({ params }: { params: Promise<{ slug:
8593 } ) ,
8694 } }
8795 />
96+ < div className = "flex flex-col items-center rounded-xl gap-8 w-full py-12" >
97+ </ div >
8898 < div className = "max-w-[900px] min-h-screen mx-auto justify-center items-center py-24" >
8999 < div className = "flex flex-col items-center rounded-xl gap-8 w-full" >
90100 < h1 className = "title font-semibold text-4xl tracking-tighter leading-tight text-center font-[family-name:var(--font-main)]" >
@@ -101,9 +111,33 @@ export default async function CourseModule({ params }: { params: Promise<{ slug:
101111 </ div >
102112 ) }
103113 </ div >
104- < article className = "prose prose-lg max-w-none font-[family-name:var(--font-sans)]" >
114+ < article className = "prose prose-lg pb-12 max-w-none font-[family-name:var(--font-sans)]" >
105115 { await CustomMDX ( { source : courseModule . content } ) }
106116 </ article >
117+ < div className = "flex flex-row w-full py-12 justify-between border-t border-neutral-200" >
118+ { prevModule ? (
119+ < Link href = { `/course/${ prevModule . slug } ` } >
120+ < Button variant = "default" className = "rounded-full" >
121+ Previous
122+ </ Button >
123+ </ Link >
124+ ) : (
125+ < Button variant = "default" disabled className = "rounded-full" >
126+ Previous
127+ </ Button >
128+ ) }
129+ { nextModule ? (
130+ < Link href = { `/course/${ nextModule . slug } ` } >
131+ < Button variant = "default" className = "rounded-full" >
132+ Next: { nextModule . metadata . title }
133+ </ Button >
134+ </ Link >
135+ ) : (
136+ < Button variant = "default" disabled className = "rounded-full" >
137+ End
138+ </ Button >
139+ ) }
140+ </ div >
107141 </ div >
108142 </ section >
109143 )
0 commit comments