From c907e95b002560d5a363d6a65c1ca0d7bcb7c691 Mon Sep 17 00:00:00 2001 From: Trang Le Date: Mon, 27 Jun 2022 10:57:26 +0000 Subject: [PATCH 1/2] feat(types): add interface for Params --- lib/types.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/types.ts b/lib/types.ts index 37b25ba..835c301 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -1,4 +1,5 @@ import { ExtendedRecordMap, PageMap } from 'notion-types' +import { ParsedUrlQuery } from 'querystring' export * from 'notion-types' @@ -16,6 +17,10 @@ export interface PageProps { error?: PageError } +export interface Params extends ParsedUrlQuery { + pageId: string +} + export interface Site { name: string domain: string From 6e6cf3a88a16e4eda407db3ed8fc7ca7b3526d6f Mon Sep 17 00:00:00 2001 From: Trang Le Date: Mon, 27 Jun 2022 10:58:19 +0000 Subject: [PATCH 2/2] feat: add type safety for getStaticProps --- pages/[pageId].tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pages/[pageId].tsx b/pages/[pageId].tsx index b92d68b..b9d573f 100644 --- a/pages/[pageId].tsx +++ b/pages/[pageId].tsx @@ -1,10 +1,12 @@ import * as React from 'react' +import { GetStaticProps } from 'next' import { isDev, domain } from 'lib/config' import { getSiteMap } from 'lib/get-site-map' import { resolveNotionPage } from 'lib/resolve-notion-page' +import { PageProps, Params } from 'lib/types' import { NotionPage } from 'components' -export const getStaticProps = async (context) => { +export const getStaticProps: GetStaticProps = async (context) => { const rawPageId = context.params.pageId as string try {