From fded1df2aa10596889b9773878672dfedffae5a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D8=AD=D8=B3=DB=8C=D9=86=20=D9=85=D8=B9=D8=B5=D9=88=D9=85?=
=?UTF-8?q?=DB=8C=20=D9=BE=D9=88=D8=B1?=
Date: Tue, 10 Dec 2024 23:35:22 +0330
Subject: [PATCH] fix product brand and text brand and title product
---
components/AppsComponent/BrandData/page.jsx | 28 ++++++++++--
.../AppsComponent/CategoriesData/page.jsx | 7 +++
src/app/brands/[...id]/page.jsx | 18 +++++++-
src/app/categories/[...id]/page.jsx | 26 +++++------
src/app/products/[...id]/page.jsx | 45 +++++++++++--------
5 files changed, 85 insertions(+), 39 deletions(-)
diff --git a/components/AppsComponent/BrandData/page.jsx b/components/AppsComponent/BrandData/page.jsx
index 96ca68b..e9ba150 100644
--- a/components/AppsComponent/BrandData/page.jsx
+++ b/components/AppsComponent/BrandData/page.jsx
@@ -10,10 +10,10 @@ import PersianNumber from "plugins/PersianNumber";
import logo from "../../../public/images/logo.png";
import AppContext from "@ctx/AppContext";
import CardNormal from "@comp/Cards/CardNormal/page";
+import Link from "next/link";
-const BrandData = ({ params, data }) => {
+const BrandData = ({ params, data, product }) => {
const CTX = useContext(AppContext);
- const hairCosmeticData = CTX.state.hairCosmeticData;
useEffect(() => {
CTX.fetchHairCosmetic();
@@ -40,13 +40,35 @@ const BrandData = ({ params, data }) => {
+
+
- {hairCosmeticData?.products?.map((e) => (
+ {product?.products?.map((e) => (
))}
+
+ {product?.products?.length >= 19 && (
+
+
+
+
+ مشاهده بیشتر{" "}
+
+
+
+
+ )}
diff --git a/components/AppsComponent/CategoriesData/page.jsx b/components/AppsComponent/CategoriesData/page.jsx
index 2525827..d8f6eb1 100644
--- a/components/AppsComponent/CategoriesData/page.jsx
+++ b/components/AppsComponent/CategoriesData/page.jsx
@@ -249,6 +249,13 @@ export default function CategoriesData({ params, products }) {
/>
)}
+ {/* */}
+
>
);
diff --git a/src/app/brands/[...id]/page.jsx b/src/app/brands/[...id]/page.jsx
index 7ce296e..be7a527 100644
--- a/src/app/brands/[...id]/page.jsx
+++ b/src/app/brands/[...id]/page.jsx
@@ -17,6 +17,21 @@ async function getData(id) {
return post;
}
+async function getProduct(id) {
+ const res = await fetch(
+ `${process.env.NEXT_PUBLIC_API_URL}/product/?page=0&brandIds=${id}`,
+ {
+ cache: "no-cache",
+ }
+ );
+ const post = await res.json();
+
+ if (post.statusCode === 404) {
+ return notFound(); // Exit the function
+ }
+ return post;
+}
+
// export async function generateMetadata({ params }) {
// const data = await getData(params.id[0]);
@@ -75,10 +90,11 @@ async function getData(id) {
const Page = async ({ params }) => {
const data = await getData(params.id[0]);
+ const product = await getProduct(params.id[0]);
return (
<>
-
+
>
);
};
diff --git a/src/app/categories/[...id]/page.jsx b/src/app/categories/[...id]/page.jsx
index bee8833..5449296 100644
--- a/src/app/categories/[...id]/page.jsx
+++ b/src/app/categories/[...id]/page.jsx
@@ -6,29 +6,23 @@ export async function generateMetadata({ params }) {
const products = await fetchProducts(params?.["id"]?.[0]);
return {
- title: products.seo.title != "" ? products.seo.title : decodedName,
+ title: products?.seo?.title != "" ? products?.seo?.title : decodedName,
description:
- products.seo.description != ""
- ? products.seo.description
+ products?.seo?.description != ""
+ ? products?.seo?.description
: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
metadataBase: new URL(
`https://www.vesmeh.com/categories/${params.id[0]}/${decodedName}`
),
- keywords: [
- "آرایشی",
- "بهداشت خانگی",
- "محصولات زیبایی",
- "لوازم تمیزی",
- "مراقبت شخصی",
- ],
+
alternates: {
canonical: `https://www.vesmeh.com/categories/${params.id[0]}/${decodedName}`,
},
openGraph: {
- title: products.seo.title != "" ? products.seo.title : decodedName,
+ title: products?.seo?.title != "" ? products?.seo?.title : decodedName,
description:
- products.seo.description != ""
- ? products.seo.description
+ products?.seo?.description != ""
+ ? products?.seo?.description
: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
url: `https://www.vesmeh.com/categories/${params.id[0]}/${decodedName}`,
type: "website",
@@ -36,10 +30,10 @@ export async function generateMetadata({ params }) {
twitter: {
site: "@vesmehstore",
description:
- products.seo.description != ""
- ? products.seo.description
+ products?.seo?.description != ""
+ ? products?.seo?.description
: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
- title: products.seo.title != "" ? products.seo.title : decodedName,
+ title: products?.seo?.title != "" ? products?.seo?.title : decodedName,
creator: "@vesmehstore",
},
};
diff --git a/src/app/products/[...id]/page.jsx b/src/app/products/[...id]/page.jsx
index fe29347..8e2cf1d 100644
--- a/src/app/products/[...id]/page.jsx
+++ b/src/app/products/[...id]/page.jsx
@@ -75,27 +75,30 @@ export async function generateMetadata({ params }) {
};
return {
- title: data?.product?.persianName,
- description:
- data?.product?.summery ||
- `خرید ${data?.product?.persianName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
+ title: !!data?.product.metaTags.find((e) => e.type == "title")
+ ? data?.product.metaTags.find((e) => e.type == "title")?.value
+ : data?.product?.persianName,
+ description: !!data?.product.metaTags.find((e) => e.type == "description")
+ ? data?.product.metaTags.find((e) => e.type == "description")?.value
+ : data?.product?.summery != ""
+ ? data?.product?.summery
+ : `خرید ${data?.product?.persianName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
+
metadataBase: metadataUrl,
product_id_meta: data?.product?.id,
alternates: {
canonical: metadataUrl,
},
- keywords: [
- "آرایشی",
- "بهداشت خانگی",
- "محصولات زیبایی",
- "لوازم تمیزی",
- "مراقبت شخصی",
- ],
+
openGraph: {
- title: data?.product?.persianName,
- description:
- data?.product?.summery ||
- `خرید ${data?.product?.persianName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
+ title: !!data?.product.metaTags.find((e) => e.type == "title")
+ ? data?.product.metaTags.find((e) => e.type == "title")?.value
+ : data?.product?.persianName,
+ description: !!data?.product.metaTags.find((e) => e.type == "description")
+ ? data?.product.metaTags.find((e) => e.type == "description")?.value
+ : data?.product?.summery != ""
+ ? data?.product?.summery
+ : `خرید ${data?.product?.persianName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
images: [imageUrl.toString()],
url: metadataUrl,
type: "website",
@@ -103,10 +106,14 @@ export async function generateMetadata({ params }) {
},
twitter: {
site: "@vesmehstore",
- description:
- data?.product?.summery ||
- `خرید ${data?.product?.persianName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
- title: data?.product?.persianName,
+ title: !!data?.product.metaTags.find((e) => e.type == "title")
+ ? data?.product.metaTags.find((e) => e.type == "title")?.value
+ : data?.product?.persianName,
+ description: !!data?.product.metaTags.find((e) => e.type == "description")
+ ? data?.product.metaTags.find((e) => e.type == "description")?.value
+ : data?.product?.summery != ""
+ ? data?.product?.summery
+ : `خرید ${data?.product?.persianName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
creator: "@vesmehstore",
},
other: {