Skip to content

Commit 7da0835

Browse files
committed
test: update homepage to test isr i18n
1 parent 3f62a61 commit 7da0835

File tree

2 files changed

+35
-28
lines changed

2 files changed

+35
-28
lines changed

demos/default/pages/index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ const Index = ({ shows, nodeEnv }) => {
1717
<div>
1818
<Header />
1919

20-
<p>This is a demo of a NextJS application with Server-Side Rendering (SSR).</p>
20+
<p>This is a demo of a NextJS application with Incremental Static Regeneration (ISR).</p>
2121

22-
<h2>Server-Side Rendering</h2>
22+
<h2>Incremental Static Regeneration</h2>
2323

2424
<p>
25-
This page is server-side rendered. It fetches a random list of five TV shows from the TVmaze REST API. Refresh
26-
this page to see it change.
25+
This page is rendered by an On-Demand Builder (ODB) function. It fetches a random list of five TV shows from
26+
the TVmaze REST API. After 60 seconds, the ODB cache is invalidated and the page will be re-rendered on the
27+
next request.
2728
</p>
2829
<code>NODE_ENV: {nodeEnv}</code>
2930

@@ -176,7 +177,7 @@ const Index = ({ shows, nodeEnv }) => {
176177
)
177178
}
178179

179-
Index.getInitialProps = async function () {
180+
export async function getStaticProps(context) {
180181
const dev = process.env.CONTEXT !== 'production'
181182

182183
// Set a random page between 1 and 100
@@ -190,7 +191,13 @@ Index.getInitialProps = async function () {
190191
const res = await fetch(server)
191192
const data = await res.json()
192193

193-
return { shows: data.slice(0, 5), nodeEnv: process.env.NODE_ENV || null }
194+
return {
195+
props: {
196+
shows: data.slice(0, 5),
197+
nodeEnv: process.env.NODE_ENV || null,
198+
},
199+
revalidate: 60,
200+
}
194201
}
195202

196203
export default Index

test/__snapshots__/index.spec.js.snap

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,10 @@ Array [
567567
"to": "/fr/",
568568
},
569569
Object {
570-
"force": false,
570+
"force": true,
571571
"from": "/",
572572
"status": 200,
573-
"to": "/.netlify/functions/___netlify-handler",
573+
"to": "/.netlify/builders/___netlify-odb-handler",
574574
},
575575
Object {
576576
"from": "/_ipx/*",
@@ -752,10 +752,10 @@ Array [
752752
"to": "/.netlify/functions/___netlify-handler",
753753
},
754754
Object {
755-
"force": false,
755+
"force": true,
756756
"from": "/_next/data/build-id/en/index.json",
757757
"status": 200,
758-
"to": "/.netlify/functions/___netlify-handler",
758+
"to": "/.netlify/builders/___netlify-odb-handler",
759759
},
760760
Object {
761761
"force": false,
@@ -811,6 +811,12 @@ Array [
811811
"status": 200,
812812
"to": "/.netlify/functions/___netlify-handler",
813813
},
814+
Object {
815+
"force": true,
816+
"from": "/_next/data/build-id/es.json",
817+
"status": 200,
818+
"to": "/.netlify/builders/___netlify-odb-handler",
819+
},
814820
Object {
815821
"force": false,
816822
"from": "/_next/data/build-id/es/500.json",
@@ -949,12 +955,6 @@ Array [
949955
"status": 200,
950956
"to": "/.netlify/functions/___netlify-handler",
951957
},
952-
Object {
953-
"force": false,
954-
"from": "/_next/data/build-id/es/index.json",
955-
"status": 200,
956-
"to": "/.netlify/functions/___netlify-handler",
957-
},
958958
Object {
959959
"force": false,
960960
"from": "/_next/data/build-id/es/layouts.json",
@@ -1009,6 +1009,12 @@ Array [
10091009
"status": 200,
10101010
"to": "/.netlify/functions/___netlify-handler",
10111011
},
1012+
Object {
1013+
"force": true,
1014+
"from": "/_next/data/build-id/fr.json",
1015+
"status": 200,
1016+
"to": "/.netlify/builders/___netlify-odb-handler",
1017+
},
10121018
Object {
10131019
"force": false,
10141020
"from": "/_next/data/build-id/fr/500.json",
@@ -1147,12 +1153,6 @@ Array [
11471153
"status": 200,
11481154
"to": "/.netlify/functions/___netlify-handler",
11491155
},
1150-
Object {
1151-
"force": false,
1152-
"from": "/_next/data/build-id/fr/index.json",
1153-
"status": 200,
1154-
"to": "/.netlify/functions/___netlify-handler",
1155-
},
11561156
Object {
11571157
"force": false,
11581158
"from": "/_next/data/build-id/fr/layouts.json",
@@ -1308,10 +1308,10 @@ Array [
13081308
"to": "/.netlify/functions/___netlify-handler",
13091309
},
13101310
Object {
1311-
"force": false,
1312-
"from": "/es/",
1311+
"force": true,
1312+
"from": "/es",
13131313
"status": 200,
1314-
"to": "/.netlify/functions/___netlify-handler",
1314+
"to": "/.netlify/builders/___netlify-odb-handler",
13151315
},
13161316
Object {
13171317
"force": false,
@@ -1512,10 +1512,10 @@ Array [
15121512
"to": "/.netlify/functions/___netlify-handler",
15131513
},
15141514
Object {
1515-
"force": false,
1516-
"from": "/fr/",
1515+
"force": true,
1516+
"from": "/fr",
15171517
"status": 200,
1518-
"to": "/.netlify/functions/___netlify-handler",
1518+
"to": "/.netlify/builders/___netlify-odb-handler",
15191519
},
15201520
Object {
15211521
"force": false,

0 commit comments

Comments
 (0)