@@ -8,25 +8,27 @@ import { RepoCard } from './_components/repo-card';
8
8
import { Sorter } from './_components/sorter' ;
9
9
import { StarsFilter } from './_components/stars-filter' ;
10
10
import { Pagination } from './_components/pagination' ;
11
- import { Suspense } from 'react' ;
12
- import type { RepoData , RepoItem , RepoResponse } from '@/types' ;
11
+ import type { RepoData , RepoItem , RepoResponse , SearchParams } from '@/types' ;
13
12
import type { Metadata } from 'next' ;
14
13
import { auth } from '@/auth' ;
15
14
16
15
interface ReposPageProps {
17
- params : { language : string } ;
18
- searchParams : Record < string , string | string [ ] | undefined > ;
16
+ params : Promise < { language : string } > ;
17
+ searchParams : Promise < SearchParams > ;
19
18
}
20
19
21
20
export default async function ReposPage ( {
22
- params : { language } ,
21
+ params,
23
22
searchParams
24
23
} : ReposPageProps ) {
25
- const key = JSON . stringify ( searchParams ) ;
26
- const { repos, page } = await getRepos ( language , searchParams ) ;
24
+ const { language } = await params ;
25
+ const sp = await searchParams ;
26
+
27
+ const key = JSON . stringify ( sp ) ;
28
+ const { repos, page } = await getRepos ( language , sp ) ;
27
29
28
30
return (
29
- < Suspense fallback = { < p > Loading... </ p > } key = { key } >
31
+ < >
30
32
< Header />
31
33
< ScrollToTop />
32
34
< div className = "container mx-auto" >
@@ -36,10 +38,8 @@ export default async function ReposPage({
36
38
< h1 className = "mb-5 text-5xl font-medium uppercase text-hacktoberfest-light-green" >
37
39
{ repos . total_count } repositories for{ ' ' }
38
40
< span className = "font-mono font-bold text-hacktoberfest-pink" >
39
- { searchParams . q
40
- ? searchParams . q +
41
- ' in ' +
42
- capitalize ( decodeURIComponent ( language ) )
41
+ { sp . q
42
+ ? sp . q + ' in ' + capitalize ( decodeURIComponent ( language ) )
43
43
: capitalize ( decodeURIComponent ( language ) ) }
44
44
</ span >
45
45
</ h1 >
@@ -56,22 +56,25 @@ export default async function ReposPage({
56
56
< Pagination
57
57
page = { page }
58
58
totalCount = { repos . total_count }
59
- searchParams = { searchParams }
59
+ searchParams = { sp }
60
60
/>
61
61
</ div >
62
- </ Suspense >
62
+ </ >
63
63
) ;
64
64
}
65
65
66
- export function generateMetadata ( { params } : ReposPageProps ) : Metadata {
66
+ export async function generateMetadata ( {
67
+ params
68
+ } : ReposPageProps ) : Promise < Metadata > {
69
+ const { language } = await params ;
67
70
return {
68
- title : `${ capitalize ( decodeURIComponent ( params . language ) ) } Repositories`
71
+ title : `${ capitalize ( decodeURIComponent ( language ) ) } Repositories`
69
72
} ;
70
73
}
71
74
72
75
async function getRepos (
73
76
language : string ,
74
- searchParams : ReposPageProps [ 'searchParams' ]
77
+ searchParams : SearchParams
75
78
) : Promise < RepoResponse > {
76
79
const client = getXataClient ( ) ;
77
80
const session = await auth ( ) ;
@@ -144,7 +147,7 @@ async function getRepos(
144
147
145
148
async function getReportedRepos ( ) {
146
149
const client = getXataClient ( ) ;
147
- const reports = await client . db . reports
150
+ const reports = await client . db . reports
148
151
. select ( [ 'repoId' ] )
149
152
. filter ( { valid : false } )
150
153
. getMany ( ) ;
0 commit comments