Skip to content

feat(page): update NodePageProps to use Promises for params and searhParams #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@ type NodePageParams = {
slug: string[]
}
type NodePageProps = {
params: NodePageParams
searchParams: { [key: string]: string | string[] | undefined }
params: Promise<NodePageParams>
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}

export async function generateMetadata(
{ params: { slug } }: NodePageProps,
{ params }: NodePageProps,
_: ResolvingMetadata
): Promise<Metadata> {
const slug = (await params).slug
let node
try {
node = await getNode(slug)
Expand Down Expand Up @@ -118,7 +119,9 @@ export async function generateStaticParams(): Promise<NodePageParams[]> {
].map(({ path }) => ({ slug: path.split("/").filter(Boolean) }))
}

export default async function Page({ params: { slug } }: NodePageProps) {
export default async function Page({ params }: NodePageProps) {
const slug = (await params).slug

const draft = await draftMode()
const isDraftMode = draft.isEnabled

Expand Down