Skip to content

Commit

Permalink
Merge pull request transitive-bullshit#330 from bytrangle/getStaticPr…
Browse files Browse the repository at this point in the history
…ops-type-checking

feat: add type safety for getStaticProps
  • Loading branch information
transitive-bullshit authored Jun 27, 2022
2 parents 1fdecd6 + 6e6cf3a commit d2c0037
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ExtendedRecordMap, PageMap } from 'notion-types'
import { ParsedUrlQuery } from 'querystring'

export * from 'notion-types'

Expand All @@ -16,6 +17,10 @@ export interface PageProps {
error?: PageError
}

export interface Params extends ParsedUrlQuery {
pageId: string
}

export interface Site {
name: string
domain: string
Expand Down
4 changes: 3 additions & 1 deletion pages/[pageId].tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit d2c0037

Please sign in to comment.