88 */ 
99
1010import  *  as  basePage  from  '@/app/[locale]/page' ; 
11- import  {  ENABLE_STATIC_EXPORT  }  from  '@/next.constants.mjs' ; 
11+ import  { 
12+   ENABLE_STATIC_EXPORT_LOCALE , 
13+   ENABLE_STATIC_EXPORT , 
14+ }  from  '@/next.constants.mjs' ; 
1215import  {  dynamicRouter  }  from  '@/next.dynamic.mjs' ; 
13- import  {  availableLocaleCodes  }  from  '@/next.locales.mjs' ; 
16+ import  {  availableLocaleCodes ,   defaultLocale  }  from  '@/next.locales.mjs' ; 
1417
1518// This is the default Viewport Metadata 
1619// @see  https://nextjs.org/docs/app/api-reference/functions/generate-viewport#generateviewport-function 
@@ -20,21 +23,35 @@ export const generateViewport = basePage.generateViewport;
2023// @see  https://nextjs.org/docs/app/api-reference/functions/generate-metadata 
2124export  const  generateMetadata  =  basePage . generateMetadata ; 
2225
23- // This provides all the possible paths that can be generated statically 
24- // + provides all the paths that we support on the Node.js Website 
26+ // Generates all possible static paths based on the locales and environment configuration 
27+ // - Returns an empty array if static export is disabled (`ENABLE_STATIC_EXPORT` is false) 
28+ // - If `ENABLE_STATIC_EXPORT_LOCALE` is true, generates paths for all available locales 
29+ // - Otherwise, generates paths only for the default locale 
30+ // @see  https://nextjs.org/docs/app/api-reference/functions/generate-static-params 
2531export  const  generateStaticParams  =  async  ( )  =>  { 
26-   const  allAvailableRoutes  =  await  Promise . all ( 
27-     // Gets all mapped routes to the Next.js Routing Engine by Locale 
28-     availableLocaleCodes . map ( async  ( locale : string )  =>  { 
29-       const  routesForLanguage  =  await  dynamicRouter . getRoutesByLanguage ( locale ) ; 
30- 
31-       return  routesForLanguage . map ( pathname  => 
32-         dynamicRouter . mapPathToRoute ( locale ,  pathname ) 
33-       ) ; 
34-     } ) 
35-   ) ; 
36- 
37-   return  ENABLE_STATIC_EXPORT  ? allAvailableRoutes . flat ( ) . sort ( )  : [ ] ; 
32+   // Return an empty array if static export is disabled 
33+   if  ( ! ENABLE_STATIC_EXPORT )  { 
34+     return  [ ] ; 
35+   } 
36+ 
37+   // Helper function to fetch and map routes for a specific locale 
38+   const  getRoutesForLocale  =  async  ( locale : string )  =>  { 
39+     const  routes  =  await  dynamicRouter . getRoutesByLanguage ( locale ) ; 
40+ 
41+     return  routes . map ( pathname  => 
42+       dynamicRouter . mapPathToRoute ( locale ,  pathname ) 
43+     ) ; 
44+   } ; 
45+ 
46+   // Determine which locales to include in the static export 
47+   const  locales  =  ENABLE_STATIC_EXPORT_LOCALE 
48+     ? availableLocaleCodes 
49+     : [ defaultLocale . code ] ; 
50+ 
51+   // Generates all possible routes for all available locales 
52+   const  routes  =  await  Promise . all ( locales . map ( getRoutesForLocale ) ) ; 
53+ 
54+   return  routes . flat ( ) . sort ( ) ; 
3855} ; 
3956
4057// Enforces that this route is used as static rendering 
0 commit comments