Based on your updated file structure of app/[locale]/blog/[...cat]/page.tsx, we can adjust the generateStaticParams function to match this route pattern. Here's how you can modify your code:
export async function generateStaticParams() {
const locales = ['en', 'es'];
const categories = ['hello', 'hi'];
return locales.flatMap(locale =>
categories.map(cat => ({
locale,
cat: [cat]
}))
);
}
export const dynamicParams = false;
export default async function Page({ params }: { params: { locale: string, cat: string[] } }) {
return <div>Locale: {params.locale}, Blog Category: {params.cat.join('/')}</div>;
}
This setup should generate the following routes:
/en/blog/hello
/en/blog/hi
/es/blog/hello
/es/blog/hi
However, it's important to note that there are known issues with generateStaticParams and internationalization in Next.js 14, as reported in the GitHub Issue: i18n config breaks dynamic segments export with generateStaticParams (https://github.com/vercel/next.js/issues/46622).
If you encounter problems with this setup, you might need to consider alternative approaches, such as:
- Handling locale routing in middleware instead of using file-based routing for locales.
- Using
getStaticPaths in the Pages Router, if that's an option for your project.
- Exploring the use of
export const dynamic = 'force-static' as mentioned in some of the GitHub issue comments.
If you continue to face issues, it might be worth creating a minimal reproduction of your problem and sharing it on the Next.js GitHub repository for more targeted assistance from the Next.js team or community.