Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update return shape of generateStaticParams #40965

Merged
merged 1 commit into from Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next/build/utils.ts
Expand Up @@ -1126,7 +1126,7 @@ export async function buildAppStaticPaths({
const result = await curGenerate.generateStaticParams({ params })
// TODO: validate the result is valid here or wait for
// buildStaticPaths to validate?
for (const item of result.params) {
for (const item of result) {
newParams.push({ ...params, ...item })
}
}
Expand Down
42 changes: 18 additions & 24 deletions test/e2e/app-dir/app-static/app/blog/[author]/[slug]/page.js
Expand Up @@ -20,34 +20,28 @@ export function generateStaticParams({ params }) {

switch (params.author) {
case 'tim': {
return {
params: [
{
slug: 'first-post',
},
],
}
return [
{
slug: 'first-post',
},
]
}
case 'seb': {
return {
params: [
{
slug: 'second-post',
},
],
}
return [
{
slug: 'second-post',
},
]
}
case 'styfle': {
return {
params: [
{
slug: 'first-post',
},
{
slug: 'second-post',
},
],
}
return [
{
slug: 'first-post',
},
{
slug: 'second-post',
},
]
}
default: {
throw new Error(`unexpected author param received ${params.author}`)
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/app-dir/app-static/app/blog/[author]/layout.js
Expand Up @@ -10,7 +10,5 @@ export default function Layout({ children, params }) {
export function generateStaticParams({ params }) {
console.log('/blog/[author] generateStaticParams', JSON.stringify(params))

return {
params: [{ author: 'tim' }, { author: 'seb' }, { author: 'styfle' }],
}
return [{ author: 'tim' }, { author: 'seb' }, { author: 'styfle' }]
}