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 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 }) => {
|
|||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div
|
||||
id="blog-content"
|
||||
dangerouslySetInnerHTML={{ __html: data.description }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid xs:grid-cols-1 lg:grid-cols-5 gap-5">
|
||||
{hairCosmeticData?.products?.map((e) => (
|
||||
{product?.products?.map((e) => (
|
||||
<div className="relative">
|
||||
<CardNormal data={e} priority />
|
||||
</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>
|
||||
|
|
|
@ -249,6 +249,13 @@ export default function CategoriesData({ params, products }) {
|
|||
/>
|
||||
)}
|
||||
|
||||
{/* <div>
|
||||
<div
|
||||
id="blog-content"
|
||||
dangerouslySetInnerHTML={{ __html: data.description }}
|
||||
/>
|
||||
</div> */}
|
||||
|
||||
<Footer />
|
||||
</>
|
||||
);
|
||||
|
|
|
@ -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 (
|
||||
<>
|
||||
<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]);
|
||||
|
||||
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",
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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: {
|
||||
|
|
Loading…
Reference in New Issue