Files
nguyencongpc_nextjs/src/app/[slug]/page.tsx

33 lines
1.0 KiB
TypeScript
Raw Normal View History

2025-12-24 17:05:16 +07:00
'use client';
import { useParams } from 'next/navigation';
2025-12-29 23:46:30 +07:00
import NotFound from '../pages/404';
import { resolvePageType } from '@/lib/resolvePageType';
2025-12-30 16:47:24 +07:00
import CategoryPage from '@/app/pages/Product/Category';
import ProductDetailPage from '@/app/pages/Product/ProductDetail';
import ArticlePage from '@/app/pages/Article/HomeArticlePage';
import ArticleCategoryPage from '@/app/pages/Article/CategoryPage';
import ArticleDetailPage from '@/app/pages/Article/DetailPage';
2025-12-24 17:05:16 +07:00
export default function DynamicPage() {
2025-12-26 10:27:02 +07:00
const { slug } = useParams();
const fullSlug = '/' + slug;
2025-12-24 17:05:16 +07:00
2025-12-26 10:27:02 +07:00
const pageType = resolvePageType(fullSlug);
2025-12-24 17:05:16 +07:00
2025-12-26 10:27:02 +07:00
switch (pageType) {
case 'category':
return <CategoryPage slug={fullSlug} />;
2025-12-27 12:01:54 +07:00
case 'product-detail':
2025-12-26 10:27:02 +07:00
return <ProductDetailPage slug={fullSlug} />;
2025-12-29 23:46:30 +07:00
case 'article-home':
return <ArticlePage />;
2025-12-30 16:47:24 +07:00
case 'article-category':
return <ArticleCategoryPage slug={fullSlug} />;
case 'article-detail':
return <ArticleDetailPage slug={fullSlug} />;
2025-12-26 10:27:02 +07:00
default:
2025-12-29 23:46:30 +07:00
return <NotFound />;
2025-12-26 10:27:02 +07:00
}
2025-12-24 17:05:16 +07:00
}