1+ import { type Metadata } from "next" ;
12import { redirect } from "next/navigation" ;
3+ import { type JSX } from "react" ;
24import { type ViewType } from "react-diff-view" ;
35import { createSimplePackageSpec } from "^/lib/createSimplePackageSpec" ;
46import { DEFAULT_DIFF_FILES_GLOB } from "^/lib/default-diff-files" ;
@@ -15,11 +17,14 @@ import PackagephobiaDiff from "./_page/PackagephobiaDiff";
1517import { type DIFF_TYPE_PARAM_NAME } from "./_page/paramNames" ;
1618
1719export interface DiffPageProps {
18- params : { parts : string | string [ ] } ;
19- searchParams : QueryParams & { [ DIFF_TYPE_PARAM_NAME ] : ViewType } ;
20+ params : Promise < { parts : string | string [ ] } > ;
21+ searchParams : Promise < QueryParams & { [ DIFF_TYPE_PARAM_NAME ] : ViewType } > ;
2022}
2123
22- export function generateMetadata ( { params : { parts } } : DiffPageProps ) {
24+ export async function generateMetadata ( {
25+ params,
26+ } : DiffPageProps ) : Promise < Metadata > {
27+ const { parts } = await params ;
2328 const specs = splitParts ( decodeParts ( parts ) ) ;
2429
2530 const [ a , b ] = specs . map ( ( spec ) => createSimplePackageSpec ( spec ) ) ;
@@ -31,18 +36,19 @@ export function generateMetadata({ params: { parts } }: DiffPageProps) {
3136}
3237
3338const DiffPage = async ( {
34- params : { parts } ,
39+ params,
3540 searchParams,
3641} : DiffPageProps ) : Promise < JSX . Element > => {
37- const { diffFiles, ...optionsQuery } = searchParams ;
42+ const { parts } = await params ;
43+ const { diffFiles, ...optionsQuery } = await searchParams ;
3844
3945 const specsOrVersions = splitParts ( decodeParts ( parts ) ) ;
4046 const { redirect : redirectTarget , canonicalSpecs } =
4147 await destination ( specsOrVersions ) ;
4248
4349 if ( redirectTarget !== false ) {
4450 const specsStr = specsToDiff ( canonicalSpecs ) ;
45- const searchStr = Object . entries ( searchParams )
51+ const searchStr = Object . entries ( await searchParams )
4652 . map ( ( [ key , value ] ) => `${ key } =${ value } ` )
4753 . join ( "&" ) ;
4854
0 commit comments