feat(router): layout slug props [breaking behavior]#2035
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
commit: |
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: dai-shi <490574+dai-shi@users.noreply.github.com>
Resolved the merge conflict in |
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: dai-shi <490574+dai-shi@users.noreply.github.com>
Resolved the merge conflict in |
close #1665
Summary
This PR adds slug props support for layouts by introducing a breaking change in static layout behavior.
Layout slug props
Before this PR, layouts only received
children, even when the layout path itself contained dynamic segments.With this PR, layouts receive slug props, but only for parent path.
Examples:
For
/en/blog/hello:{ lang: 'en' }slug{ lang: 'en', slug: 'hello' }Breaking behavioral change
This PR also changes how static layouts are cached.
Previously, a static layout under a dynamic segment was effectively shared. That is no longer the case. Static layout is rendered and cached for each path.
So if we have routes like,
/en/blog/hello/ja/blog/helloThe layout example above will render twice for
/enand/ja.Migration path for shared static UI: use a static slice
If your intent was to share one static wrapper across many slug variants, the recommended migration path is to move that shared part into a static slice.
Before
After
This keeps the shared wrapper static and reusable, while avoiding incorrect sharing of slug-dependent layout output. You can use the slice in a layout too rather than the page.
Notes
createPages.