feat: implement core e-learning pages, course composable, and i18n localization.
This commit is contained in:
parent
f736eb7f38
commit
e94410d0e7
9 changed files with 235 additions and 138 deletions
|
|
@ -13,7 +13,7 @@ definePageMeta({
|
|||
const route = useRoute()
|
||||
// ดึง courseId จาก URL params (แปลงเป็น integer)
|
||||
const courseId = computed(() => parseInt(route.params.id as string))
|
||||
const { fetchCourseById, enrollCourse } = useCourse()
|
||||
const { fetchCourseById, enrollCourse, getLocalizedText } = useCourse()
|
||||
|
||||
// ใช้ useAsyncData ดึงข้อมูลคอร์ส Server-side rendering (SSR)
|
||||
// Key: 'course-{id}' เพื่อให้ cache แยกกันตาม ID
|
||||
|
|
@ -54,12 +54,6 @@ const handleEnroll = async () => {
|
|||
}
|
||||
|
||||
|
||||
const getLocalizedText = (text: string | { th: string; en: string } | undefined | null) => {
|
||||
if (!text) return ''
|
||||
if (typeof text === 'string') return text
|
||||
// @ts-ignore
|
||||
return text.th || text.en || ''
|
||||
}
|
||||
|
||||
|
||||
useHead({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue