Unverified Commit 0f41a48f authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update return shape of generateStaticParams (#40965)

x-ref: [slack
thread](https://vercel.slack.com/archives/C035J346QQL/p1664290658055079)
parent e0cc9cd4
......@@ -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 })
}
}
......
......@@ -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}`)
......
......@@ -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' }]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment