Skip to content

Commit

Permalink
Add getStaticPropsContext type
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Jul 15, 2022
1 parent bba7395 commit 1ad01b6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/next/server/app-render.tsx
Expand Up @@ -655,6 +655,17 @@ export async function renderToHTML(
pathname: string
}

type GetStaticPropsContext = {
layoutSegments: FlightSegmentPath
params?: { [key: string]: string | string[] }
preview?: boolean
previewData?: string | object | undefined
}

type GetStaticPropContextPage = GetStaticPropsContext & {
pathname: string
}

// TODO-APP: pass a shared cache from previous getStaticProps/getServerSideProps calls?
if (layoutOrPageMod.getServerSideProps) {
// TODO-APP: recommendation for i18n
Expand All @@ -681,7 +692,9 @@ export async function renderToHTML(
}
// TODO-APP: implement layout specific caching for getStaticProps
if (layoutOrPageMod.getStaticProps) {
const getStaticPropsContext = {
const getStaticPropsContext:
| GetStaticPropsContext
| GetStaticPropContextPage = {
layoutSegments: segmentPath,
...(isPage ? { pathname } : {}),
...(pageIsDynamic ? { params: currentParams } : undefined),
Expand Down

0 comments on commit 1ad01b6

Please sign in to comment.