From 18e4fb0786a8ec05c02601862e536b2c894cb5fd Mon Sep 17 00:00:00 2001 From: mpn <123456> Date: Sun, 31 Mar 2024 09:19:15 +0330 Subject: [PATCH] torob tags --- components/AppsComponent/ProductData/page.jsx | 34 ++++++++-------- src/app/products/[...id]/page.jsx | 39 ++++++++++++++++++- 2 files changed, 55 insertions(+), 18 deletions(-) diff --git a/components/AppsComponent/ProductData/page.jsx b/components/AppsComponent/ProductData/page.jsx index 15323f4..e337c3f 100644 --- a/components/AppsComponent/ProductData/page.jsx +++ b/components/AppsComponent/ProductData/page.jsx @@ -9,7 +9,7 @@ import Image from "next/image"; import PersianNumber from "plugins/PersianNumber"; import logo from "../../../public/images/logo.png"; -const ProductData = ({ params }) => { +const ProductData = ({ params, data }) => { const [product, setProduct] = useState([]); const [specificationsHeader, setSpecificationsHeader] = useState([]); const [productBarDetail, setProductBarDetail] = useState(0); @@ -65,14 +65,16 @@ const ProductData = ({ params }) => {
- +
-

{product.persianName}

+

+ {data.product?.persianName}{" "} +

- {product?.englishName}{" "} + {data?.product?.englishName}{" "}

@@ -81,13 +83,13 @@ const ProductData = ({ params }) => {

اصالت کالای

- {product?.hasDiscount && ( + {data?.product?.hasDiscount && (

بمب امروز

)} - {!product?.warranty == "" && ( + {!data?.product?.warranty == "" && (

{product?.warranty} @@ -109,7 +111,7 @@ const ProductData = ({ params }) => {

- {product?.summery} + {data?.product?.summery}

@@ -132,7 +134,7 @@ const ProductData = ({ params }) => {
- {product.files?.length > 0 ? ( + {data?.product?.files?.length > 0 ? ( {

- {product.persianName}{" "} + {data?.product?.persianName}{" "}

@@ -199,7 +201,7 @@ const ProductData = ({ params }) => {
@@ -209,7 +211,7 @@ const ProductData = ({ params }) => {

@@ -227,7 +229,7 @@ const ProductData = ({ params }) => { تومان
)} - +
@@ -361,7 +363,7 @@ const ProductData = ({ params }) => {

@@ -371,7 +373,7 @@ const ProductData = ({ params }) => {

@@ -383,13 +385,13 @@ const ProductData = ({ params }) => { {" "}

تومان
)} - +
diff --git a/src/app/products/[...id]/page.jsx b/src/app/products/[...id]/page.jsx index e91f682..cb82758 100644 --- a/src/app/products/[...id]/page.jsx +++ b/src/app/products/[...id]/page.jsx @@ -1,14 +1,25 @@ import ProductData from "@comp/AppsComponent/ProductData/page"; +async function getData(id) { + const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/product/${id}`); + const post = await res.json(); + return post; +} + export async function generateMetadata({ params }) { + const data = await getData(params.id[0]); + const decodedName = decodeURIComponent(params.id[1]); + console.log("dddddd", data?.product); + return { title: decodedName, description: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`, metadataBase: new URL( `https://www.vesmeh.com/categories/${params.id[0]}/${decodedName}` ), + product_id_meta: data?.product?.id, keywords: [ "آرایشی", "بهداشت خانگی", @@ -21,6 +32,19 @@ export async function generateMetadata({ params }) { description: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`, url: `https://www.vesmeh.com/categories/${params.id[0]}/${decodedName}`, type: "website", + + images: [ + { + url: JSON.stringify( + process.env.NEXT_PUBLIC_STORAGE_URL + "/" + data?.product?.files && + data?.product?.files[0].fileLocation + ), // Dynamic og route + width: 800, + height: 600, + }, + ], + locale: "en_US", + type: "website", }, twitter: { site: "@vesmehstore", @@ -28,12 +52,23 @@ export async function generateMetadata({ params }) { title: decodedName, creator: "@vesmehstore", }, + other: { + product_id: data?.product?.id, + product_name: data?.product?.persianName, + product_price: data?.product?.costWithDiscount, + product_old_price: data?.product?.cost, + availability: data?.product?.stock > 0 ? "instock" : "outofstock", + guarantee: "guarantee_sample", + }, }; } -const Page = ({ params }) => { + +const Page = async ({ params }) => { + const data = await getData(params.id[0]); + return ( <> - + ); };