Feature Request: Include generateStaticParams Function in Generated layout.tsx Files
Description
There is an issue in the current version of the package where the generateStaticParams function is not being included in the generated layout.tsx files. This function is useful for specifying static parameters direclty from layout in Nextjs app router.
Steps to Reproduce
Create a new nextjs application with npx create-next-app
Install next-roots and its dependencies
Provide a basic roots.config.js file
Move src/app/layout.tsx and src/app/page.tsx under src/roots/
Create a layout.tsx file under a src/roots/[category] directory.
Export a generateStaticParams function from the layout.tsx file.
Use the package to generate files under the src/app/ directory.
export default function CategoryLayout({ children }: { children: React.ReactNode }) {
return <>{children}</>
}
export async function generateStaticParams(props: any) {
return [{ category: 'a' }, { category: 'b' }]
}
Generated src/app/(en)/[category]/layout.tsx
import CategoryLayoutOrigin from '../../../roots/[category]/layout'
export default function CategoryLayout(props:any) {
{/* @ts-ignore */}
return <CategoryLayoutOrigin {...props} locale="en" />
}
// `generateStaticParams` function is missing here
Expected Behavior
The generateStaticParams function should be included in the generated layout.tsx files.
Feature Request: Include
generateStaticParams
Function in Generatedlayout.tsx
FilesDescription
There is an issue in the current version of the package where the
generateStaticParams
function is not being included in the generatedlayout.tsx
files. This function is useful for specifying static parameters direclty from layout in Nextjs app router.Steps to Reproduce
npx create-next-app
next-roots
and its dependenciesroots.config.js
filesrc/app/layout.tsx
andsrc/app/page.tsx
undersrc/roots/
layout.tsx
file under asrc/roots/[category]
directory.generateStaticParams
function from thelayout.tsx
file.src/app/
directory.Example:
roots.config.js
src/roots/[category]/layout.tsx
Generated
src/app/(en)/[category]/layout.tsx
Expected Behavior
The
generateStaticParams
function should be included in the generatedlayout.tsx
files.Expected Generated
src/app/(en)/[category]/layout.tsx
Environment
Proposed Solution
Include the
generateStaticParams
function from the originallayout.tsx
file in the generatedlayout.tsx
files.Pull Request
I work on a PR for this.
Additional Context
Related to Issue #242
Feel free to reach out if you need any additional information or clarification regarding this issue.