-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
130 additions
and
25 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
.../librelingo-web/src/app/[sourceLanguageCode]/courses/[targetLanguageCode]/module-card.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Button } from '@/components/ui/button' | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardFooter, | ||
CardHeader, | ||
CardTitle, | ||
} from '@/components/ui/card' | ||
import { CourseDetail, Module } from '@/data/course' | ||
import Link from 'next/link' | ||
|
||
type Props = { | ||
course: CourseDetail | ||
module: Module | ||
} | ||
|
||
export default function ModuleCard({ course, module }: Props) { | ||
const coursePageUrl = `/${course.sourceLanguage.code}/courses/${course.targetLanguage.code}/courses/${module.slug}` | ||
|
||
return ( | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>{module.title}</CardTitle> | ||
<CardDescription>Card Description</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<p>Card Content</p> | ||
</CardContent> | ||
<CardFooter> | ||
<Button asChild> | ||
<Link href={coursePageUrl}>Learn</Link> | ||
</Button> | ||
</CardFooter> | ||
</Card> | ||
) | ||
} |
44 changes: 30 additions & 14 deletions
44
apps/librelingo-web/src/app/[sourceLanguageCode]/courses/[targetLanguageCode]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,40 @@ | ||
import { getCourseDetail, getCourseId, listAvailableCourses } from "@/data/course" | ||
import { | ||
getCourseDetail, | ||
getCourseId, | ||
listAvailableCourses, | ||
} from '@/data/course' | ||
import ModuleCard from './module-card' | ||
|
||
export async function generateStaticParams() { | ||
const courses = await listAvailableCourses() | ||
const courses = await listAvailableCourses() | ||
|
||
return courses.map((course) => ({ | ||
sourceLanguageCode: course.uiLanguage, | ||
targetLanguageCode: course.languageCode, | ||
})) | ||
return courses.map((course) => ({ | ||
sourceLanguageCode: course.uiLanguage, | ||
targetLanguageCode: course.languageCode, | ||
})) | ||
} | ||
|
||
type Props = { | ||
params: { | ||
sourceLanguageCode: string | ||
targetLanguageCode: string | ||
} | ||
params: { | ||
sourceLanguageCode: string | ||
targetLanguageCode: string | ||
} | ||
} | ||
|
||
export default async function CourseHomePage({params}: Props) { | ||
const courseId = await getCourseId(params) | ||
const detail = await getCourseDetail(courseId) | ||
export default async function CourseHomePage({ params }: Props) { | ||
const courseId = await getCourseId(params) | ||
const detail = await getCourseDetail(courseId) | ||
|
||
return <h1>{detail.targetLanguage.name}</h1> | ||
return ( | ||
<> | ||
<h1>{detail.targetLanguage.name}</h1> | ||
<ul className="flex space-y-6 flex-col p-6"> | ||
{detail.modules.map((module) => ( | ||
<li key={module.slug}> | ||
<ModuleCard course={detail} module={module} /> | ||
</li> | ||
))} | ||
</ul> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
}, | ||
"modules": [ | ||
{ | ||
"slug": "basics", | ||
"title": "Basics", | ||
"skills": [ | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import path from 'node:path' | ||
|
||
export function getAbsoluteCoursePath(jsonPath: string) { | ||
return path.join(process.cwd(), 'src', 'courses', jsonPath) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters