Skip to content

Commit

Permalink
fix generateStaticParams case
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed May 23, 2024
1 parent f78ef00 commit 5f26360
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,21 @@ export async function buildAppStaticPaths({
const newParams: Params[] = []

if (curGenerate.generateStaticParams) {
const curStore =
ComponentMod.staticGenerationAsyncStorage.getStore()

if (curStore) {
if (typeof curGenerate?.config?.fetchCache !== 'undefined') {
curStore.fetchCache = curGenerate.config.fetchCache
}
if (typeof curGenerate?.config?.revalidate !== 'undefined') {
curStore.revalidate = curGenerate.config.revalidate
}
if (curGenerate?.config?.dynamic === 'force-dynamic') {
curStore.forceDynamic = true
}
}

for (const params of paramsItems) {
const result = await curGenerate.generateStaticParams({
params,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const dynamicParams = true
export const fetchCache = 'default-cache'

export async function generateStaticParams() {
const res = await fetch(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const dynamicParams = false
export const fetchCache = 'default-cache'

export async function generateStaticParams() {
const res = await fetch(
Expand Down

0 comments on commit 5f26360

Please sign in to comment.