upload 29/12
This commit is contained in:
43
src/app/[slug]/page.tsx
Normal file
43
src/app/[slug]/page.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import { findBySlug } from "@/lib/slugMap";
|
||||
|
||||
import ProductCategory from "@/components/product/Category";
|
||||
import ProductDetail from "@/components/product/ProductDetail";
|
||||
import ArticleHome from "@/components/article/Home";
|
||||
import ArticleCategory from "@/components/article/Category";
|
||||
import ArticleDetail from "@/components/article/ArticleDetail";
|
||||
|
||||
|
||||
export default async function SlugPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ slug: string }>;
|
||||
}) {
|
||||
const { slug } = await params;
|
||||
|
||||
if (!slug) return notFound();
|
||||
|
||||
const result = findBySlug(slug);
|
||||
|
||||
if (!result) return notFound();
|
||||
|
||||
switch (result.type) {
|
||||
case "product_category":
|
||||
return <ProductCategory slug={slug} />;
|
||||
|
||||
case "product_detail":
|
||||
return <ProductDetail slug={slug} />;
|
||||
|
||||
case "article_home":
|
||||
return <ArticleHome slug={slug} />;
|
||||
|
||||
case "article_category":
|
||||
return <ArticleCategory slug={slug} />;
|
||||
|
||||
case "article_detail":
|
||||
return <ArticleDetail slug={slug} />;
|
||||
|
||||
default:
|
||||
return notFound();
|
||||
}
|
||||
}
|
||||
BIN
src/app/favicon.ico
Normal file
BIN
src/app/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
28
src/app/layout.tsx
Normal file
28
src/app/layout.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { Metadata } from "next";
|
||||
import type { ReactNode } from 'react';
|
||||
import Header from "@/components/other/Header";
|
||||
import Footer from "@/components/other/Footer";
|
||||
import '../styles/globals.css';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Local Pc",
|
||||
description: "hoanghapc",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<html lang="vi">
|
||||
<body>
|
||||
<Header />
|
||||
|
||||
{children}
|
||||
|
||||
<Footer />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
8
src/app/not-found.tsx
Normal file
8
src/app/not-found.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<div style={{ padding: 40 }}>
|
||||
<h1>404</h1>
|
||||
<p>Trang không tồn tại</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
10
src/app/page.tsx
Normal file
10
src/app/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
import Home from "@/components/home";
|
||||
|
||||
export default function HomePage() {
|
||||
return (
|
||||
<>
|
||||
<Home />
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user