File tree 4 files changed +82
-0
lines changed
tests/fixtures/page-router-404-get-static-props-with-revalidate
4 files changed +82
-0
lines changed Original file line number Diff line number Diff line change
1
+ /** @type {import('next').NextConfig } */
2
+ const nextConfig = {
3
+ output : 'standalone' ,
4
+ eslint : {
5
+ ignoreDuringBuilds : true ,
6
+ } ,
7
+ generateBuildId : ( ) => 'build-id' ,
8
+ }
9
+
10
+ module . exports = nextConfig
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " page-router-404-get-static-props-with-revalidate" ,
3
+ "version" : " 0.1.0" ,
4
+ "private" : true ,
5
+ "scripts" : {
6
+ "postinstall" : " next build" ,
7
+ "dev" : " next dev" ,
8
+ "build" : " next build"
9
+ },
10
+ "dependencies" : {
11
+ "next" : " latest" ,
12
+ "react" : " 18.2.0" ,
13
+ "react-dom" : " 18.2.0"
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ export default function NotFound ( { timestamp } ) {
2
+ return (
3
+ < p >
4
+ Custom 404 page with revalidate: < pre data-testid = "timestamp" > { timestamp } </ pre >
5
+ </ p >
6
+ )
7
+ }
8
+
9
+ /** @type {import('next').GetStaticProps } */
10
+ export const getStaticProps = ( { locale } ) => {
11
+ return {
12
+ props : {
13
+ timestamp : Date . now ( ) ,
14
+ } ,
15
+ revalidate : 300 ,
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ const Product = ( { time, slug } ) => (
2
+ < div >
3
+ < h1 > Product { slug } </ h1 >
4
+ < p >
5
+ This page uses getStaticProps() and getStaticPaths() to pre-fetch a Product
6
+ < span data-testid = "date-now" > { time } </ span >
7
+ </ p >
8
+ </ div >
9
+ )
10
+
11
+ /** @type {import('next').GetStaticProps } */
12
+ export async function getStaticProps ( { params } ) {
13
+ if ( params . slug === 'not-found-no-revalidate' ) {
14
+ return {
15
+ notFound : true ,
16
+ }
17
+ } else if ( params . slug === 'not-found-with-revalidate' ) {
18
+ return {
19
+ notFound : true ,
20
+ revalidate : 600 ,
21
+ }
22
+ }
23
+
24
+ return {
25
+ props : {
26
+ time : new Date ( ) . toISOString ( ) ,
27
+ slug : params . slug ,
28
+ } ,
29
+ }
30
+ }
31
+
32
+ /** @type {import('next').GetStaticPaths } */
33
+ export const getStaticPaths = ( ) => {
34
+ return {
35
+ paths : [ ] ,
36
+ fallback : 'blocking' , // false or "blocking"
37
+ }
38
+ }
39
+
40
+ export default Product
You can’t perform that action at this time.
0 commit comments