index.js
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import InnerDetails from "@/components/Collection/InnerDetails";
import Breadcrumb from "@/components/Common/Breadcrumb";
import HeadTitle from "@/components/Common/HeadTitle";
import { getCollectionPageData } from "@/services/collectionApi";
import { getCollectionCategoryBySlug } from "@/services/collectionCategoryApi";
import { getCollectionSubCategoryData } from "@/services/collectionSubCategoryApi";
export default function CategoryPage({ categoryData, categoriesSub,collectionDataa }) {
if (!categoryData) {
return <h1>Category not found</h1>;
}
const breadcrumbData = [
// { href: "/", label: "Home" },
{ href: "/", label: "Collections" },
{
href: `/collections/${categoryData.slug}`,
label: categoryData.title,
},
];
// const headTitleData = {
// title: categoryData.title,
// descrition1: "",
// descrition2: "",
// };
return (
<>
<Breadcrumb breadcrumbData={breadcrumbData} />
<HeadTitle categoryData={categoryData} />
{categoriesSub.length > 0 && (
<InnerDetails subCategories={categoriesSub} />
)}
</>
);
}
export async function getServerSideProps({ params }) {
try {
const { category } = params;
const categoryData = await getCollectionCategoryBySlug(category);
const categoriesSub = await getCollectionSubCategoryData(category);
// const collectionDataa = await getCollectionPageData(category);
return {
props: {
categoryData,
categoriesSub,
// collectionDataa
},
};
} catch (error) {
return {
props: {
categoryData: null,
categoriesSub: [],
// collectionDataa:[]
},
};
}
}