Skip to content

Commit 1dd7c26

Browse files
committed
test: update homepage to test isr i18n
1 parent 81ce185 commit 1dd7c26

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.js.snap

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,10 @@ Array [
454454
"to": "/fr/",
455455
},
456456
Object {
457-
"force": false,
457+
"force": true,
458458
"from": "/",
459459
"status": 200,
460-
"to": "/.netlify/functions/___netlify-handler",
460+
"to": "/.netlify/builders/___netlify-odb-handler",
461461
},
462462
Object {
463463
"from": "/_ipx/*",
@@ -633,10 +633,10 @@ Array [
633633
"to": "/.netlify/functions/___netlify-handler",
634634
},
635635
Object {
636-
"force": false,
636+
"force": true,
637637
"from": "/_next/data/build-id/en/index.json",
638638
"status": 200,
639-
"to": "/.netlify/functions/___netlify-handler",
639+
"to": "/.netlify/builders/___netlify-odb-handler",
640640
},
641641
Object {
642642
"force": false,
@@ -692,6 +692,12 @@ Array [
692692
"status": 200,
693693
"to": "/.netlify/functions/___netlify-handler",
694694
},
695+
Object {
696+
"force": true,
697+
"from": "/_next/data/build-id/es.json",
698+
"status": 200,
699+
"to": "/.netlify/builders/___netlify-odb-handler",
700+
},
695701
Object {
696702
"force": false,
697703
"from": "/_next/data/build-id/es/500.json",
@@ -824,12 +830,6 @@ Array [
824830
"status": 200,
825831
"to": "/.netlify/functions/___netlify-handler",
826832
},
827-
Object {
828-
"force": false,
829-
"from": "/_next/data/build-id/es/index.json",
830-
"status": 200,
831-
"to": "/.netlify/functions/___netlify-handler",
832-
},
833833
Object {
834834
"force": false,
835835
"from": "/_next/data/build-id/es/layouts.json",
@@ -884,6 +884,12 @@ Array [
884884
"status": 200,
885885
"to": "/.netlify/functions/___netlify-handler",
886886
},
887+
Object {
888+
"force": true,
889+
"from": "/_next/data/build-id/fr.json",
890+
"status": 200,
891+
"to": "/.netlify/builders/___netlify-odb-handler",
892+
},
887893
Object {
888894
"force": false,
889895
"from": "/_next/data/build-id/fr/500.json",
@@ -1016,12 +1022,6 @@ Array [
10161022
"status": 200,
10171023
"to": "/.netlify/functions/___netlify-handler",
10181024
},
1019-
Object {
1020-
"force": false,
1021-
"from": "/_next/data/build-id/fr/index.json",
1022-
"status": 200,
1023-
"to": "/.netlify/functions/___netlify-handler",
1024-
},
10251025
Object {
10261026
"force": false,
10271027
"from": "/_next/data/build-id/fr/layouts.json",
@@ -1177,10 +1177,10 @@ Array [
11771177
"to": "/.netlify/functions/___netlify-handler",
11781178
},
11791179
Object {
1180-
"force": false,
1181-
"from": "/es/",
1180+
"force": true,
1181+
"from": "/es",
11821182
"status": 200,
1183-
"to": "/.netlify/functions/___netlify-handler",
1183+
"to": "/.netlify/builders/___netlify-odb-handler",
11841184
},
11851185
Object {
11861186
"force": false,
@@ -1375,10 +1375,10 @@ Array [
13751375
"to": "/.netlify/functions/___netlify-handler",
13761376
},
13771377
Object {
1378-
"force": false,
1379-
"from": "/fr/",
1378+
"force": true,
1379+
"from": "/fr",
13801380
"status": 200,
1381-
"to": "/.netlify/functions/___netlify-handler",
1381+
"to": "/.netlify/builders/___netlify-odb-handler",
13821382
},
13831383
Object {
13841384
"force": false,

0 commit comments

Comments
 (0)