From c820340030ac2bbaa98a963f7ced6622c9836e87 Mon Sep 17 00:00:00 2001 From: Hichem Fantar Date: Thu, 30 Jan 2025 04:04:31 +0100 Subject: [PATCH 1/2] fix: handle optional slug parameter in page routing --- .../app/[lang]/remote/graphql-eslint/[[...slug]]/page.tsx | 4 ++-- .../app/[lang]/remote/graphql-yoga/[[...slug]]/page.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/swr-site/app/[lang]/remote/graphql-eslint/[[...slug]]/page.tsx b/examples/swr-site/app/[lang]/remote/graphql-eslint/[[...slug]]/page.tsx index 649de1f740..c1214cf5f9 100644 --- a/examples/swr-site/app/[lang]/remote/graphql-eslint/[[...slug]]/page.tsx +++ b/examples/swr-site/app/[lang]/remote/graphql-eslint/[[...slug]]/page.tsx @@ -54,13 +54,13 @@ const { wrapper: Wrapper, ...components } = useMDXComponents({ type PageProps = Readonly<{ params: Promise<{ - slug: string[] + slug?: string[] }> }> export default async function Page(props: PageProps) { const params = await props.params - const route = params.slug.join('/') + const route = params.slug ? params.slug.join('/') : '' const filePath = mdxPages[route] if (!filePath) { diff --git a/examples/swr-site/app/[lang]/remote/graphql-yoga/[[...slug]]/page.tsx b/examples/swr-site/app/[lang]/remote/graphql-yoga/[[...slug]]/page.tsx index 7dd64218c5..ec06b0204b 100644 --- a/examples/swr-site/app/[lang]/remote/graphql-yoga/[[...slug]]/page.tsx +++ b/examples/swr-site/app/[lang]/remote/graphql-yoga/[[...slug]]/page.tsx @@ -70,13 +70,13 @@ const { wrapper: Wrapper, ...components } = useMDXComponents({ type PageProps = Readonly<{ params: Promise<{ - slug: string[] + slug?: string[] }> }> export default async function Page(props: PageProps) { const params = await props.params - const route = params.slug.join('/') + const route = params.slug ? params.slug.join('/') : '' const filePath = mdxPages[route] if (!filePath) { From 5ae7b0314d66d3fdf9e77ee1f55404e50c8cac22 Mon Sep 17 00:00:00 2001 From: Hichem Fantar Date: Thu, 30 Jan 2025 04:22:02 +0100 Subject: [PATCH 2/2] fix: use optional chaining for slug parameter in page routing --- .../app/[lang]/remote/graphql-eslint/[[...slug]]/page.tsx | 2 +- .../app/[lang]/remote/graphql-yoga/[[...slug]]/page.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/swr-site/app/[lang]/remote/graphql-eslint/[[...slug]]/page.tsx b/examples/swr-site/app/[lang]/remote/graphql-eslint/[[...slug]]/page.tsx index c1214cf5f9..7a55623bf1 100644 --- a/examples/swr-site/app/[lang]/remote/graphql-eslint/[[...slug]]/page.tsx +++ b/examples/swr-site/app/[lang]/remote/graphql-eslint/[[...slug]]/page.tsx @@ -60,7 +60,7 @@ type PageProps = Readonly<{ export default async function Page(props: PageProps) { const params = await props.params - const route = params.slug ? params.slug.join('/') : '' + const route = params.slug?.join('/') ?? '' const filePath = mdxPages[route] if (!filePath) { diff --git a/examples/swr-site/app/[lang]/remote/graphql-yoga/[[...slug]]/page.tsx b/examples/swr-site/app/[lang]/remote/graphql-yoga/[[...slug]]/page.tsx index ec06b0204b..7f84990814 100644 --- a/examples/swr-site/app/[lang]/remote/graphql-yoga/[[...slug]]/page.tsx +++ b/examples/swr-site/app/[lang]/remote/graphql-yoga/[[...slug]]/page.tsx @@ -76,7 +76,7 @@ type PageProps = Readonly<{ export default async function Page(props: PageProps) { const params = await props.params - const route = params.slug ? params.slug.join('/') : '' + const route = params.slug?.join('/') ?? '' const filePath = mdxPages[route] if (!filePath) {