Skip to content

Commit 45c6526

Browse files
committed
fix: don't use ISR for appDir pages
1 parent 686ac61 commit 45c6526

File tree

11 files changed

+187
-47
lines changed

11 files changed

+187
-47
lines changed

demos/default/.vscode/settings.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"typescript.tsdk": "../../node_modules/typescript/lib",
3+
"typescript.enablePromptUseWorkspaceTsdk": true
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { notFound } from 'next/navigation'
2+
3+
export const revalidate = null
4+
5+
export const dynamicParams = true
6+
7+
export default function Page({ params }) {
8+
if (params.author === 'matt') {
9+
return notFound()
10+
}
11+
return (
12+
<>
13+
<p id="page">/blog/[author]/[slug]</p>
14+
<p id="params">{JSON.stringify(params)}</p>
15+
<p id="date">{Date.now()}</p>
16+
</>
17+
)
18+
}
19+
20+
export function generateStaticParams({ params }: any) {
21+
console.log('/blog/[author]/[slug] generateStaticParams', JSON.stringify(params))
22+
23+
switch (params.author) {
24+
case 'erica': {
25+
return [
26+
{
27+
slug: 'first-post',
28+
},
29+
]
30+
}
31+
case 'sarah': {
32+
return [
33+
{
34+
slug: 'second-post',
35+
},
36+
]
37+
}
38+
case 'nick': {
39+
return [
40+
{
41+
slug: 'first-post',
42+
},
43+
{
44+
slug: 'second-post',
45+
},
46+
]
47+
}
48+
case 'rob': {
49+
return [
50+
{
51+
slug: 'second-post',
52+
},
53+
]
54+
}
55+
56+
default: {
57+
throw new Error(`unexpected author param received ${params.author}`)
58+
}
59+
}
60+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default function Layout({ children, params }) {
2+
return (
3+
<>
4+
<p id="author-layout-params">{JSON.stringify(params)}</p>
5+
{children}
6+
</>
7+
)
8+
}
9+
10+
export function generateStaticParams(params) {
11+
console.log('/blog/[author] generateStaticParams', JSON.stringify(params))
12+
13+
return [{ author: 'nick' }, { author: 'sarah' }, { author: 'rob' }, { author: 'erica' }]
14+
}
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import Link from 'next/link'
2+
3+
export const dynamicParams = false
4+
5+
export default async function Page({ params }) {
6+
await fetch('https://example.vercel.sh', {
7+
next: { revalidate: 10 },
8+
})
9+
return (
10+
<>
11+
<p id="page">/blog/[author]</p>
12+
<p id="params">{JSON.stringify(params)}</p>
13+
<p id="date">{Date.now()}</p>
14+
<Link href="/blog/erica" id="author-1">
15+
/blog/erica
16+
</Link>
17+
<br />
18+
<Link href="/blog/sarah" id="author-2">
19+
/blog/sarah
20+
</Link>
21+
<br />
22+
<Link href="/blog/nick" id="author-3">
23+
/blog/nick
24+
</Link>
25+
<br />
26+
27+
<Link href="/blog/erica/first-post" id="author-1-post-1">
28+
/blog/erica/first-post
29+
</Link>
30+
<br />
31+
<Link href="/blog/sarah/second-post" id="author-2-post-1">
32+
/blog/sarah/second-post
33+
</Link>
34+
<br />
35+
<Link href="/blog/nick/first-post" id="author-3-post-1">
36+
/blog/nick/first-post
37+
</Link>
38+
<br />
39+
</>
40+
)
41+
}

demos/default/app/layout.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default function Layout({ children }) {
2+
return (
3+
<html lang="en">
4+
<head>
5+
<title>my static blog</title>
6+
</head>
7+
<body>{children}</body>
8+
</html>
9+
)
10+
}

demos/default/next.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,6 @@ module.exports = {
8484
},
8585
experimental: {
8686
optimizeCss: false,
87+
appDir: true,
8788
},
8889
}

demos/default/tsconfig.json

+9-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@
1111
"moduleResolution": "node",
1212
"resolveJsonModule": true,
1313
"isolatedModules": true,
14-
"jsx": "preserve"
14+
"jsx": "preserve",
15+
"plugins": [
16+
{
17+
"name": "next"
18+
}
19+
]
1520
},
1621
"include": [
1722
"next-env.d.ts",
1823
"**/*.ts",
19-
"**/*.tsx"
24+
"**/*.tsx",
25+
".next/types/**/*.ts"
2026
],
2127
"exclude": [
2228
"node_modules"
2329
]
24-
}
30+
}

0 commit comments

Comments
 (0)