Skip to content

Commit d2c0037

Browse files
Merge pull request #330 from bytrangle/getStaticProps-type-checking
feat: add type safety for getStaticProps
2 parents 1fdecd6 + 6e6cf3a commit d2c0037

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ExtendedRecordMap, PageMap } from 'notion-types'
2+
import { ParsedUrlQuery } from 'querystring'
23

34
export * from 'notion-types'
45

@@ -16,6 +17,10 @@ export interface PageProps {
1617
error?: PageError
1718
}
1819

20+
export interface Params extends ParsedUrlQuery {
21+
pageId: string
22+
}
23+
1924
export interface Site {
2025
name: string
2126
domain: string

pages/[pageId].tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import * as React from 'react'
2+
import { GetStaticProps } from 'next'
23
import { isDev, domain } from 'lib/config'
34
import { getSiteMap } from 'lib/get-site-map'
45
import { resolveNotionPage } from 'lib/resolve-notion-page'
6+
import { PageProps, Params } from 'lib/types'
57
import { NotionPage } from 'components'
68

7-
export const getStaticProps = async (context) => {
9+
export const getStaticProps: GetStaticProps<PageProps, Params> = async (context) => {
810
const rawPageId = context.params.pageId as string
911

1012
try {

0 commit comments

Comments
 (0)