-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(i18n): review fallback system #9119
Conversation
🦋 Changeset detectedLatest commit: 517ffa3 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
750c04e
to
72dfaf7
Compare
`[${staticPaths.length} ${label}]` | ||
)}` | ||
); | ||
for (const route of eachRouteInRouteData(pageData)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we loop over all the routes: the main ones and the fallback routes associated to it
const matchedRoute = matchRoute(staticPath, opts.manifest); | ||
return matchedRoute === route; | ||
}); | ||
paths.push( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We chain all the generated routes all together
} | ||
|
||
pipeline.getEnvironment().logger.debug('build', `Generating: ${pathname}`); | ||
for (const route of eachRouteInRouteData(pageData)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only relevant change is that the whole logic is inside this loop now, and instead of doing pageData.route
, we pass the route
from this loop
Changes
This PR closes #9108
The was a big flaw in the logic of the fallback, so I went back, and restored how the routes were stored before the introduction of the fallback logic.
The new change involves the introduction of
fallbackRoutes
as part of theRouteData
object, very very similar to how we do it forredirectRoutes
.Although, now the generation of the pages is different, and each
RouteData
could create more than one page (itself +fallbackRoutes
), hence I create a generator function calledeachRouteInRouteData
, which returns all the routes we need to create.EDIT:
In SSR, the middleware already has the logic for doing the redirect, although we need to tell it somehow. So I updated the logic of
app/index.ts
.The
match
function now considers' fallbackRoutes' when matching a route. However, when returning aResponse
, we set a status code 302 because we want the fallback to apply.Example:
it
toen
/it/blog/article
route/en/blog/article
, because it contains a fallback route that has a pathname that matches/it/blog/article
302
status code. The middleware catches the status code and returns a redirect to/en/blog/article
Testing
I added a new case where we check the presence of a hoisted script.
The other rests should still pass.
Docs