Fix params/searchParams types for Next.js app router
This commit is contained in:
@@ -1,25 +1,18 @@
|
||||
import { RootPage, generatePageMetadata } from '@payloadcms/next/views';
|
||||
import type { Metadata } from 'next';
|
||||
import config from '../../../../payload.config';
|
||||
import { importMap } from '../importMap';
|
||||
|
||||
export type PayloadRouteParams = {
|
||||
segments?: string[];
|
||||
};
|
||||
|
||||
export type PayloadRouteSearchParams = {
|
||||
[key: string]: string | string[] | undefined;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
params: PayloadRouteParams;
|
||||
searchParams: PayloadRouteSearchParams;
|
||||
params: Promise<{ segments?: string[] }>;
|
||||
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
||||
};
|
||||
|
||||
export const generateMetadata = (props: Props) => {
|
||||
export const generateMetadata = (props: Props): Promise<Metadata> => {
|
||||
return generatePageMetadata({
|
||||
config,
|
||||
params: Promise.resolve(props.params) as Promise<{ [key: string]: string | string[] }>,
|
||||
searchParams: Promise.resolve(props.searchParams) as Promise<{ [key: string]: string | string[] }>,
|
||||
params: props.params as Promise<{ [key: string]: string | string[] }>,
|
||||
searchParams: props.searchParams as Promise<{ [key: string]: string | string[] }>,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -27,7 +20,7 @@ export default function Page(props: Props) {
|
||||
return RootPage({
|
||||
config,
|
||||
importMap,
|
||||
params: Promise.resolve(props.params) as Promise<{ segments: string[] }>,
|
||||
searchParams: Promise.resolve(props.searchParams) as Promise<{ [key: string]: string | string[] }>,
|
||||
params: props.params as Promise<{ segments: string[] }>,
|
||||
searchParams: props.searchParams as Promise<{ [key: string]: string | string[] }>,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user