I am using NextJS 14 and i have the following folder structure:
clients
|-page.tsx
|
|-[anagrafiche_id]
|-layout.tsx
|-page.tsx
|-pageComponents.tsx
|
|-[doc_progetti_arch_id]
|-layout.tsx
|-page.tsx
|-pageComponents.tsx
|
|-[doc_progetti_arch_dett_id]
|-layout.tsx
|-page.tsx
|-pageComponents.tsx
inside each layout.tsx i have the function generateStaticParams
like so:
clients/[anagrafiche_id]/[doc_progetti_arch_id]/layout.tsx
export async function generateStaticParams({ params: { anagrafiche_id } }: { params: { anagrafiche_id: string } }) {
let progetti: Array<any> = await getDocProgettiArchId(anagrafiche_id);
let toReturn = [];
for (let i = 0; i < progetti.length; i++) {
toReturn.push({
doc_progetti_arch_id: progetti[i].doc_progetti_arch_id + "",
});
}
return toReturn.map((el) => el);
}
The problem:
Everything works fine at build time, but when i navigate to /clients/103/285
when the page 285 is not “compiled”, the function generateStaticProps
reruns (which is what i want) but it recalculates even all the possibilities for the first segment, when it should keep the 103 page already “compiled” and use that id to grab just the associated ids.
I don’t know if it is related, but i’m not even able to navigate to /clients/103/285
since the page stayes at /clients/103
even if the pathname has changed.