fix product brand and text brand and title product
parent
11c0a3adad
commit
fded1df2aa
|
@ -10,10 +10,10 @@ import PersianNumber from "plugins/PersianNumber";
|
||||||
import logo from "../../../public/images/logo.png";
|
import logo from "../../../public/images/logo.png";
|
||||||
import AppContext from "@ctx/AppContext";
|
import AppContext from "@ctx/AppContext";
|
||||||
import CardNormal from "@comp/Cards/CardNormal/page";
|
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 CTX = useContext(AppContext);
|
||||||
const hairCosmeticData = CTX.state.hairCosmeticData;
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
CTX.fetchHairCosmetic();
|
CTX.fetchHairCosmetic();
|
||||||
|
@ -40,13 +40,35 @@ const BrandData = ({ params, data }) => {
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
id="blog-content"
|
||||||
|
dangerouslySetInnerHTML={{ __html: data.description }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="grid xs:grid-cols-1 lg:grid-cols-5 gap-5">
|
<div className="grid xs:grid-cols-1 lg:grid-cols-5 gap-5">
|
||||||
{hairCosmeticData?.products?.map((e) => (
|
{product?.products?.map((e) => (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<CardNormal data={e} priority />
|
<CardNormal data={e} priority />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{product?.products?.length >= 19 && (
|
||||||
|
<div className="flex justify-center mt-8">
|
||||||
|
<Link
|
||||||
|
href={`/categories/0/${data?.slug}?brandIds=${data?.id}&page=0`}
|
||||||
|
className="z-90 relative"
|
||||||
|
>
|
||||||
|
<div className="mx-5 mt-8">
|
||||||
|
<p className="mb-0 text-sm text-gray-600 xs:text-white md:text-black">
|
||||||
|
مشاهده بیشتر{" "}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -249,6 +249,13 @@ export default function CategoriesData({ params, products }) {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* <div>
|
||||||
|
<div
|
||||||
|
id="blog-content"
|
||||||
|
dangerouslySetInnerHTML={{ __html: data.description }}
|
||||||
|
/>
|
||||||
|
</div> */}
|
||||||
|
|
||||||
<Footer />
|
<Footer />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,6 +17,21 @@ async function getData(id) {
|
||||||
return post;
|
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 }) {
|
// export async function generateMetadata({ params }) {
|
||||||
// const data = await getData(params.id[0]);
|
// const data = await getData(params.id[0]);
|
||||||
|
|
||||||
|
@ -75,10 +90,11 @@ async function getData(id) {
|
||||||
|
|
||||||
const Page = async ({ params }) => {
|
const Page = async ({ params }) => {
|
||||||
const data = await getData(params.id[0]);
|
const data = await getData(params.id[0]);
|
||||||
|
const product = await getProduct(params.id[0]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BrandData params={params} data={data} />
|
<BrandData params={params} data={data} product={product} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,29 +6,23 @@ export async function generateMetadata({ params }) {
|
||||||
const products = await fetchProducts(params?.["id"]?.[0]);
|
const products = await fetchProducts(params?.["id"]?.[0]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: products.seo.title != "" ? products.seo.title : decodedName,
|
title: products?.seo?.title != "" ? products?.seo?.title : decodedName,
|
||||||
description:
|
description:
|
||||||
products.seo.description != ""
|
products?.seo?.description != ""
|
||||||
? products.seo.description
|
? products?.seo?.description
|
||||||
: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
|
: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
|
||||||
metadataBase: new URL(
|
metadataBase: new URL(
|
||||||
`https://www.vesmeh.com/categories/${params.id[0]}/${decodedName}`
|
`https://www.vesmeh.com/categories/${params.id[0]}/${decodedName}`
|
||||||
),
|
),
|
||||||
keywords: [
|
|
||||||
"آرایشی",
|
|
||||||
"بهداشت خانگی",
|
|
||||||
"محصولات زیبایی",
|
|
||||||
"لوازم تمیزی",
|
|
||||||
"مراقبت شخصی",
|
|
||||||
],
|
|
||||||
alternates: {
|
alternates: {
|
||||||
canonical: `https://www.vesmeh.com/categories/${params.id[0]}/${decodedName}`,
|
canonical: `https://www.vesmeh.com/categories/${params.id[0]}/${decodedName}`,
|
||||||
},
|
},
|
||||||
openGraph: {
|
openGraph: {
|
||||||
title: products.seo.title != "" ? products.seo.title : decodedName,
|
title: products?.seo?.title != "" ? products?.seo?.title : decodedName,
|
||||||
description:
|
description:
|
||||||
products.seo.description != ""
|
products?.seo?.description != ""
|
||||||
? products.seo.description
|
? products?.seo?.description
|
||||||
: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
|
: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
|
||||||
url: `https://www.vesmeh.com/categories/${params.id[0]}/${decodedName}`,
|
url: `https://www.vesmeh.com/categories/${params.id[0]}/${decodedName}`,
|
||||||
type: "website",
|
type: "website",
|
||||||
|
@ -36,10 +30,10 @@ export async function generateMetadata({ params }) {
|
||||||
twitter: {
|
twitter: {
|
||||||
site: "@vesmehstore",
|
site: "@vesmehstore",
|
||||||
description:
|
description:
|
||||||
products.seo.description != ""
|
products?.seo?.description != ""
|
||||||
? products.seo.description
|
? products?.seo?.description
|
||||||
: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
|
: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
|
||||||
title: products.seo.title != "" ? products.seo.title : decodedName,
|
title: products?.seo?.title != "" ? products?.seo?.title : decodedName,
|
||||||
creator: "@vesmehstore",
|
creator: "@vesmehstore",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -75,27 +75,30 @@ export async function generateMetadata({ params }) {
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: data?.product?.persianName,
|
title: !!data?.product.metaTags.find((e) => e.type == "title")
|
||||||
description:
|
? data?.product.metaTags.find((e) => e.type == "title")?.value
|
||||||
data?.product?.summery ||
|
: data?.product?.persianName,
|
||||||
`خرید ${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,
|
metadataBase: metadataUrl,
|
||||||
product_id_meta: data?.product?.id,
|
product_id_meta: data?.product?.id,
|
||||||
alternates: {
|
alternates: {
|
||||||
canonical: metadataUrl,
|
canonical: metadataUrl,
|
||||||
},
|
},
|
||||||
keywords: [
|
|
||||||
"آرایشی",
|
|
||||||
"بهداشت خانگی",
|
|
||||||
"محصولات زیبایی",
|
|
||||||
"لوازم تمیزی",
|
|
||||||
"مراقبت شخصی",
|
|
||||||
],
|
|
||||||
openGraph: {
|
openGraph: {
|
||||||
title: data?.product?.persianName,
|
title: !!data?.product.metaTags.find((e) => e.type == "title")
|
||||||
description:
|
? data?.product.metaTags.find((e) => e.type == "title")?.value
|
||||||
data?.product?.summery ||
|
: data?.product?.persianName,
|
||||||
`خرید ${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()],
|
images: [imageUrl.toString()],
|
||||||
url: metadataUrl,
|
url: metadataUrl,
|
||||||
type: "website",
|
type: "website",
|
||||||
|
@ -103,10 +106,14 @@ export async function generateMetadata({ params }) {
|
||||||
},
|
},
|
||||||
twitter: {
|
twitter: {
|
||||||
site: "@vesmehstore",
|
site: "@vesmehstore",
|
||||||
description:
|
title: !!data?.product.metaTags.find((e) => e.type == "title")
|
||||||
data?.product?.summery ||
|
? data?.product.metaTags.find((e) => e.type == "title")?.value
|
||||||
`خرید ${data?.product?.persianName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`,
|
: data?.product?.persianName,
|
||||||
title: 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",
|
creator: "@vesmehstore",
|
||||||
},
|
},
|
||||||
other: {
|
other: {
|
||||||
|
|
Loading…
Reference in New Issue