File tree Expand file tree Collapse file tree 2 files changed +32
-7
lines changed
packages/runtime/src/helpers Expand file tree Collapse file tree 2 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,8 @@ const generateStaticIsrRewrites = ({
162
162
basePath,
163
163
to : ODB_FUNCTION_PATH ,
164
164
force : true ,
165
+ // produce locale-specific routes
166
+ i18n,
165
167
} ) ,
166
168
)
167
169
} else if ( matchesMiddleware ( middleware , route ) ) {
Original file line number Diff line number Diff line change @@ -183,20 +183,43 @@ export const redirectsForNextRouteWithData = ({
183
183
to,
184
184
status = 200 ,
185
185
force = false ,
186
+ i18n,
186
187
} : {
187
188
route : string
188
189
dataRoute : string
189
190
basePath : string
190
191
to : string
191
192
status ?: number
192
193
force ?: boolean
193
- } ) : NetlifyConfig [ 'redirects' ] =>
194
- generateNetlifyRoutes ( { route, dataRoute, withData : true } ) . map ( ( redirect ) => ( {
195
- from : `${ basePath } ${ redirect } ` ,
196
- to,
197
- status,
198
- force,
199
- } ) )
194
+ i18n ?: I18n
195
+ } ) : NetlifyConfig [ 'redirects' ] => {
196
+ const paths = generateNetlifyRoutes ( { route, dataRoute, withData : true } )
197
+
198
+ const routes = [ ]
199
+ if ( i18n ?. locales ?. length ) {
200
+ i18n . locales . flatMap ( ( locale ) =>
201
+ paths . map ( ( redirect ) => ( {
202
+ from : `${ basePath } ${ redirect } ` ,
203
+ to,
204
+ status,
205
+ force,
206
+ conditions : { Language : locale } ,
207
+ } ) ) ,
208
+ )
209
+ }
210
+
211
+ // rules without language condition
212
+ routes . push (
213
+ ...paths . map ( ( redirect ) => ( {
214
+ from : `${ basePath } ${ redirect } ` ,
215
+ to,
216
+ status,
217
+ force,
218
+ } ) ) ,
219
+ )
220
+
221
+ return routes
222
+ }
200
223
201
224
export const getApiRewrites = ( basePath : string , apiRoutes : Array < ApiRouteConfig > ) => {
202
225
const apiRewrites = apiRoutes . map ( ( apiRoute ) => {
You can’t perform that action at this time.
0 commit comments