From 7691e99afcc61795f568abeace680aa280f611ed Mon Sep 17 00:00:00 2001 From: Neo Date: Tue, 3 Mar 2026 17:56:21 +0000 Subject: [PATCH] Fix: Add root-level routes without locale prefix --- src/app/page.tsx | 64 ++++++++++++++++++++++++++ src/app/products/[slug]/page.tsx | 77 ++++++++++++++++++++++++++++++++ src/app/products/page.tsx | 38 ++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 src/app/page.tsx create mode 100644 src/app/products/[slug]/page.tsx create mode 100644 src/app/products/page.tsx diff --git a/src/app/page.tsx b/src/app/page.tsx new file mode 100644 index 0000000..dcca1a7 --- /dev/null +++ b/src/app/page.tsx @@ -0,0 +1,64 @@ +import { getProducts } from "@/lib/woocommerce"; +import Header from "@/components/layout/Header"; +import Footer from "@/components/layout/Footer"; +import ProductCard from "@/components/product/ProductCard"; + +export const metadata = { + title: "ManoonOils - Premium Natural Oils for Hair & Skin", + description: "Discover our premium collection of natural oils for hair and skin care.", +}; + +export default async function Homepage() { + const products = await getProducts(); + const publishedProducts = products.filter((p) => p.status === "publish").slice(0, 4); + + return ( +
+
+ +
+
+

+ ManoonOils +

+

+ Premium Natural Oils for Hair & Skin +

+ + Shop Now + +
+
+ + {publishedProducts.length > 0 && ( +
+
+

Our Products

+
+ {publishedProducts.map((product, index) => ( + + ))} +
+
+
+ )} + +
+
+

Natural & Pure

+

+ Our oils are crafted with love using only the finest natural ingredients. +

+ + Learn More + +
+
+ +
+
+ ); +} diff --git a/src/app/products/[slug]/page.tsx b/src/app/products/[slug]/page.tsx new file mode 100644 index 0000000..e0a6e58 --- /dev/null +++ b/src/app/products/[slug]/page.tsx @@ -0,0 +1,77 @@ +import { getProducts } from "@/lib/woocommerce"; +import Header from "@/components/layout/Header"; +import Footer from "@/components/layout/Footer"; + +export async function generateStaticParams() { + try { + const products = await getProducts(); + return products.map((product) => ({ + slug: product.slug || product.id.toString(), + })); + } catch { + return []; + } +} + +export default async function ProductPage({ params }: { params: Promise<{ slug: string }> }) { + const { slug } = await params; + let product = null; + + try { + const products = await getProducts(); + product = products.find((p) => (p.slug || p.id.toString()) === slug); + } catch (e) { + // Fallback + } + + if (!product) { + return ( +
+
+
+

Product not found

+
+
+
+ ); + } + + const image = product.images?.[0]?.src || '/placeholder.jpg'; + const price = product.sale_price || product.price; + + return ( +
+
+ +
+
+
+
+ {product.name} +
+ +
+

{product.name}

+ +
{price} RSD
+ +
+ + +
+
+
+
+ +
+
+ ); +} diff --git a/src/app/products/page.tsx b/src/app/products/page.tsx new file mode 100644 index 0000000..26d0894 --- /dev/null +++ b/src/app/products/page.tsx @@ -0,0 +1,38 @@ +import { getProducts } from "@/lib/woocommerce"; +import Header from "@/components/layout/Header"; +import Footer from "@/components/layout/Footer"; +import ProductCard from "@/components/product/ProductCard"; + +export const metadata = { + title: "Products - ManoonOils", + description: "Browse our premium natural oils for hair and skin.", +}; + +export default async function ProductsPage() { + const products = await getProducts(); + const publishedProducts = products.filter((p) => p.status === "publish"); + + return ( +
+
+ +
+
+

All Products

+ + {publishedProducts.length > 0 ? ( +
+ {publishedProducts.map((product, index) => ( + + ))} +
+ ) : ( +

No products available.

+ )} +
+
+ +
+ ); +}