diff --git a/lib/types.ts b/lib/types.ts index f79004f6d2..8c2294d96d 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -21,6 +21,10 @@ export interface Params extends ParsedUrlQuery { pageId: string } +export interface PageParams extends ParsedUrlQuery { + pageId: string +} + export interface Site { name: string domain: string diff --git a/pages/[pageId].tsx b/pages/[...pageId].tsx similarity index 83% rename from pages/[pageId].tsx rename to pages/[...pageId].tsx index 075187620e..963365f05a 100644 --- a/pages/[pageId].tsx +++ b/pages/[...pageId].tsx @@ -5,12 +5,12 @@ import { NotionPage } from '@/components/NotionPage' import { domain, isDev } from '@/lib/config' import { getSiteMap } from '@/lib/get-site-map' import { resolveNotionPage } from '@/lib/resolve-notion-page' -import { PageProps, Params } from '@/lib/types' +import {PageParams, PageProps} from '@/lib/types' -export const getStaticProps: GetStaticProps = async ( +export const getStaticProps: GetStaticProps = async ( context ) => { - const rawPageId = context.params.pageId as string + const rawPageId = (context.params.pageId).join('/') try { const props = await resolveNotionPage(domain, rawPageId) @@ -38,7 +38,7 @@ export async function getStaticPaths() { const staticPaths = { paths: Object.keys(siteMap.canonicalPageMap).map((pageId) => ({ params: { - pageId + pageId: pageId.split('/') } })), // paths: [],