diff --git a/src/app/[...slug]/page.tsx b/src/app/[...slug]/page.tsx new file mode 100644 index 000000000..b4c3963fb --- /dev/null +++ b/src/app/[...slug]/page.tsx @@ -0,0 +1,162 @@ +import { notFound } from 'next/navigation'; +import Image from 'next/image'; +import Link from 'next/link'; +import { productCategories } from '@/data/site-config'; + +interface Props { + params: { slug: string[] }; +} + +// Generate all possible paths from product categories +export async function generateStaticParams() { + const paths: { slug: string[] }[] = []; + + productCategories.forEach((product) => { + // Remove leading slash and split the href + const pathParts = product.href.replace(/^\//, '').split('/'); + paths.push({ slug: pathParts }); + }); + + return paths; +} + +function findProductBySlug(slug: string[]) { + const fullPath = '/' + slug.join('/'); + return productCategories.find((p) => p.href === fullPath); +} + +export async function generateMetadata({ params }: Props) { + const product = findProductBySlug(params.slug); + + if (!product) { + return { title: 'ไม่พบหน้า' }; + } + + return { + title: `${product.name} - ${product.nameEn}`, + description: product.description, + keywords: product.keywords, + }; +} + +export default function ProductDetailPage({ params }: Props) { + const product = findProductBySlug(params.slug); + + if (!product) { + notFound(); + } + + // Find related products in same category + const relatedProducts = productCategories + .filter((p) => p.slug === product.slug && p.id !== product.id) + .slice(0, 4); + + return ( +
+
+ {/* Breadcrumb */} + + +
+ {/* Product Image */} +
+ {product.name} +
+ + {/* Product Info */} +
+ {product.nameEn} +

+ {product.name} +

+

+ {product.description} +

+ + {/* CTA */} +
+ + ขอใบเสนอราคา + + + โทรสอบถาม + +
+
+
+ + {/* SEO Content */} + {product.seoContent && ( +
+
+
+
+
+ )} + + {/* Related Products */} + {relatedProducts.length > 0 && ( +
+

+ สินค้าที่เกี่ยวข้อง +

+
+ {relatedProducts.map((related) => ( + +
+ {related.name} +
+
+ + {related.nameEn} + +

+ {related.name} +

+
+ + ))} +
+
+ )} +
+
+ ); +} diff --git a/src/components/layout/Footer.tsx b/src/components/layout/Footer.tsx index a16454d40..cb388bc45 100644 --- a/src/components/layout/Footer.tsx +++ b/src/components/layout/Footer.tsx @@ -1,3 +1,4 @@ +import Image from 'next/image'; import Link from 'next/link'; import { siteConfig, workHours, mainNavigation } from '@/data/site-config'; @@ -9,15 +10,13 @@ export default function Footer() {
{/* Company Info */}
-
-
- D -
-
- {siteConfig.name} - {siteConfig.nameTh} -
-
+ Deal Plus Tech

{siteConfig.description}

diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx index 0baae01b1..57de12984 100644 --- a/src/components/layout/Header.tsx +++ b/src/components/layout/Header.tsx @@ -45,13 +45,14 @@ export default function Header() {
{/* Logo */} -
- D -
-
- {siteConfig.name} - {siteConfig.nameTh} -
+ Deal Plus Tech {/* Desktop Navigation */} diff --git a/src/data/site-config.ts b/src/data/site-config.ts index 09bf519e2..548999ea3 100644 --- a/src/data/site-config.ts +++ b/src/data/site-config.ts @@ -5,7 +5,7 @@ export const siteConfig: SiteConfig = { nameTh: 'ดีลพลัสเทค', url: 'https://dealplustech.co.th', description: 'ดีลพลัสเทค - ผู้เชี่ยวชาญด้านวัสดุท่อและอุปกรณ์ระบบท่อ ท่อพีพีอาร์ ท่อ HDPE ท่อ PVC วาล์ว และอุปกรณ์ต่อท่อครบวงจร', - phone: '02-xxx-xxxx', + phone: '090-555-1415', email: 'info@dealplustech.co.th', lineId: '@dealplustech', facebookUrl: 'https://facebook.com/dealplustech',