Merge pull request #330 from bytrangle/getStaticProps-type-checking

feat: add type safety for getStaticProps
This commit is contained in:
Travis Fischer
2022-06-27 08:21:18 -04:00
committed by GitHub
2 changed files with 8 additions and 1 deletions

View File

@@ -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

View File

@@ -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<PageProps, Params> = async (context) => {
const rawPageId = context.params.pageId as string
try {