1
- import { Metadata } from ' next' ;
2
- import { notFound } from ' next/navigation' ;
1
+ import type { Metadata } from " next" ;
2
+ import { notFound } from " next/navigation" ;
3
3
4
- import Pagination from ' components/collection/pagination' ;
5
- import Grid from ' components/grid' ;
6
- import ProductGridItems from ' components/layout/product-grid-items' ;
7
- import Collections from ' components/layout/search/collections' ;
8
- import FilterList from ' components/layout/search/filter' ;
4
+ import Pagination from " components/collection/pagination" ;
5
+ import Grid from " components/grid" ;
6
+ import ProductGridItems from " components/layout/product-grid-items" ;
7
+ import Collections from " components/layout/search/collections" ;
8
+ import FilterList from " components/layout/search/filter" ;
9
9
10
- import { defaultSort , sorting } from ' lib/constants' ;
11
- import { getCollection , getCollectionProducts } from ' lib/shopware' ;
12
- import { transformHandle } from ' lib/shopware/transform' ;
10
+ import { defaultSort , sorting } from " lib/constants" ;
11
+ import { getCollection , getCollectionProducts } from " lib/shopware" ;
12
+ import { transformHandle } from " lib/shopware/transform" ;
13
13
14
14
export async function generateMetadata ( {
15
- params
15
+ params,
16
16
} : {
17
17
params : Promise < { collection : string } > ;
18
18
} ) : Promise < Metadata > {
19
19
const { collection : collectionParamName } = await params ;
20
20
21
21
// see https://github.com/facebook/react/issues/25994
22
- const collectionName = decodeURIComponent ( transformHandle ( collectionParamName ?? '' ) ) ;
23
- if ( collectionName . includes ( '.js.map' ) ) {
22
+ const collectionName = decodeURIComponent (
23
+ transformHandle ( collectionParamName ?? "" ) ,
24
+ ) ;
25
+ if ( collectionName . includes ( ".js.map" ) ) {
24
26
return { } ;
25
27
}
26
28
@@ -31,47 +33,50 @@ export async function generateMetadata({
31
33
return {
32
34
title : collection . seo ?. title || collection . title ,
33
35
description :
34
- collection . seo ?. description || collection . description || `${ collection . title } products` ,
36
+ collection . seo ?. description ||
37
+ collection . description ||
38
+ `${ collection . title } products` ,
35
39
openGraph : collection . featuredImage
36
40
? {
37
41
images : [
38
42
{
39
- url : collection . featuredImage
40
- }
41
- ]
43
+ url : collection . featuredImage ,
44
+ } ,
45
+ ] ,
42
46
}
43
- : null
47
+ : null ,
44
48
} ;
45
49
}
46
50
47
51
export default async function CategoryPage ( {
48
52
params,
49
- searchParams
53
+ searchParams,
50
54
} : {
51
55
params : Promise < { collection : string } > ;
52
56
searchParams ?: Promise < { [ key : string ] : string | string [ ] | undefined } > ;
53
57
} ) {
54
58
const { collection } = await params ;
55
59
const { sort, page } = ( await searchParams ) as { [ key : string ] : string } ;
56
- const { sortKey, reverse } = sorting . find ( ( item ) => item . slug === sort ) || defaultSort ;
60
+ const { sortKey, reverse } =
61
+ sorting . find ( ( item ) => item . slug === sort ) || defaultSort ;
57
62
58
63
// see https://github.com/facebook/react/issues/25994
59
- const collectionName = decodeURIComponent ( transformHandle ( collection ?? '' ) ) ;
60
- if ( collectionName . includes ( ' .js.map' ) ) {
64
+ const collectionName = decodeURIComponent ( transformHandle ( collection ?? "" ) ) ;
65
+ if ( collectionName . includes ( " .js.map" ) ) {
61
66
return null ;
62
67
}
63
68
64
69
const { products, total, limit } = await getCollectionProducts ( {
65
70
collection : collectionName ,
66
- page : page ? parseInt ( page ) : 1 ,
71
+ page : page ? Number . parseInt ( page ) : 1 ,
67
72
sortKey,
68
- reverse
73
+ reverse,
69
74
} ) ;
70
75
71
76
return (
72
77
< section >
73
78
{ products . length === 0 ? (
74
- < p className = "py-3 text-lg" > { ` No products found in this collection` } </ p >
79
+ < p className = "py-3 text-lg" > No products found in this collection</ p >
75
80
) : (
76
81
< div className = "mx-auto flex max-w-screen-2xl flex-col gap-8 px-4 pb-4 text-black md:flex-row dark:text-white" >
77
82
< div className = "order-first w-full flex-none md:max-w-[125px]" >
@@ -89,7 +94,7 @@ export default async function CategoryPage({
89
94
< Pagination
90
95
itemsPerPage = { limit }
91
96
itemsTotal = { total }
92
- currentPage = { page ? parseInt ( page ) - 1 : 0 }
97
+ currentPage = { page ? Number . parseInt ( page ) - 1 : 0 }
93
98
/>
94
99
</ nav >
95
100
) : null }
0 commit comments