-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Implement new layouts system #6174
Conversation
🦋 Changeset detectedLatest commit: 7c74aa9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
||
> `default` is a reserved name — in other words, you can't have a `+layout-default.svelte` file. | ||
Not all use cases are suited for layout grouping, nor should you feel compelled to use them. It might be that your use case would result in complex `(group)` nesting, or that you don't want to introduce a `(group)` for a single outlier. It's perfectly fine to use other means such as composition (reusable `load` functions or Svelte components) or if-statements to achieve what you want. |
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.
Yes! this is so important to mention and myself overlooked it too, groups are powerful and can have footguns if not handled correctly, but as always, use the right tool for the job.
Should this be in a highlighted box?
And it would be great to elaborate on the reusable layouts or conditionals inside a single layout to establish best practices. Maybe linking to an examples repo?
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.
I enhanced the section with a little code example. For more a repository or an entry in the recipes section on learn.svelte.dev
would be good indeed - but we can do that later 😄
Co-authored-by: Conduitry <[email protected]>
Hi 😊 When will this be available? I'm asking because I did a bunch of modifications based on the docs, but now I just realized that the doc has been deployed before the package 🥹 And I don't remember how to do the previous named layout method (and no more doc on this) 😅 |
@maximedupre I just merged the release PR (#6217) so it should hit npm any minute now |
Excellent change love it |
This PR broke symlink routes ❌ symlinks break Created issue #6303 with repro EDIT: Doing a little bit of research I found the symlink issue was fixed back in PR #4957 The Fix (commit eb2ab91)
Originally posted by @mrkishi in #4957 (review) |
TODO: Reset layout. Read: <sveltejs/kit#6174>.
TODO: Reset layout. Read: <sveltejs/kit#6174>.
How to migration from named layouts
Named layouts have been removed in favor of
(groups)
. See the documentation for an introduction: https://kit.svelte.dev/docs/advanced-routing#advanced-layoutsHow to migrate highly depends on your use case:
Use case 1: Rewinding to an earlier layout / "breaking out"
If you used named layouts to rewind the layout inheritance chain to a layout higher up the tree, you can reference the segment directly now:
Use case 2: Rewinding to a blank root layout
If you had
+layout-blank.svelte
in your root to reset to a blank layout, you need to adjust your actual root layout to be blank and move that functionality into another layout further below in the tree, either using an if-statement in your root layout or using the(group)
feature:Use case 3: Different layouts for routes at the same nesting level
If you used named layouts to specify "these 2 pages get layout X and these other 2 next to them get layout Y", use groups instead.
Before:
After
Use case 4: arbitrary inheritance chains
If you previously used named layouts to enhance other named layouts, which also enhance layouts, to mix and match them, then that's no longer possible this way. In cases like this - which from reading the layout chains probably got confusing anyway - we advice to use composition and/or if-statements instead. The new documentation has a section with an example for this as inspiration.
PR description
#6124
Closes #6196 (using
(groups)
and/or composition)Closes #5763 (root layout guaranteed to always exist +
await parent()
)Closes #5311 (
[email protected]
)Closes #4940 (no longer possible to get into this situation)
Closes #2154 (only a single root layout now)
+layout-foo.svelte
write_types
dictionary
inclient-manifest.js
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0