-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure getStaticProps is called for SSG 404 in blocking mode (#18300)
This ensures that when using a `pages/404` file with `getStaticProps` that we call `getStaticProps` in `fallback: 'blocking'` mode Fixes: #18293
- Loading branch information
Showing
3 changed files
with
140 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
test/integration/i18n-support/pages/not-found/blocking-fallback/[slug].js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import Link from 'next/link' | ||
import { useRouter } from 'next/router' | ||
|
||
export default function Page(props) { | ||
const router = useRouter() | ||
|
||
return ( | ||
<> | ||
<p id="gsp">gsp page</p> | ||
<p id="props">{JSON.stringify(props)}</p> | ||
<p id="router-locale">{router.locale}</p> | ||
<p id="router-locales">{JSON.stringify(router.locales)}</p> | ||
<p id="router-query">{JSON.stringify(router.query)}</p> | ||
<p id="router-pathname">{router.pathname}</p> | ||
<p id="router-as-path">{router.asPath}</p> | ||
<Link href="/"> | ||
<a id="to-index">to /</a> | ||
</Link> | ||
<br /> | ||
</> | ||
) | ||
} | ||
|
||
export const getStaticProps = ({ params, locale, locales }) => { | ||
if (locale === 'en' || locale === 'nl') { | ||
return { | ||
notFound: true, | ||
} | ||
} | ||
|
||
return { | ||
props: { | ||
params, | ||
locale, | ||
locales, | ||
}, | ||
} | ||
} | ||
|
||
export const getStaticPaths = () => { | ||
return { | ||
// the default locale will be used since one isn't defined here | ||
paths: ['first', 'second'].map((slug) => ({ | ||
params: { slug }, | ||
})), | ||
fallback: 'blocking', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters