-
-
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
Layout resets #1061
Layout resets #1061
Conversation
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.
going to make a lot of people happy with this one! it was the #2 request from Sapper behind i18n 😄
documentation/docs/02-layouts.md
Outdated
@@ -62,6 +62,10 @@ We can create a layout that only applies to pages below `/settings` (while inher | |||
<slot></slot> | |||
``` | |||
|
|||
### Resets | |||
|
|||
To reset the layout stack, create a `$layout.reset.svelte` file. For example, if you want your `/admin/*` pages to _not_ inherit the root layout, create a file called `src/routes/admin/$layout.reset.svelte`. |
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 should say something about the contents of $layout.reset.svelte
. Would it be accurate to say:
To reset the layout stack, create an empty
$layout.reset.svelte
file.
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.
To me this sounds like it needs to be empty, which is not correct because you can start writing your new layout inside the reset file right away. Do I think the current sentence is better.
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'm not sure what would be best but I agree that the current proposed docs are a bit confusing. Maybe it would help if they said one creates the reset file instead of the regular layout file?
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.
Made it a bit clearer
Had an API that uses a module export to indicate that this is a reset layout been considered? That seems in a sense tidier than a separate file, especially since they're not allowed to coexist. Was that dismissed because it made it harder to check for at compile time? because it's harder for users to see at a glance? |
Addressed that in #626 (comment). tl;dr the manifest generator (which at present just looks at the names of files on the filesystem, and could theoretically be rewritten to take an array of strings, which is actually probably a good idea anyway) would have to a) know how to preprocess components, which incidentally implies becoming an async function, and b) be sufficiently good at static analysis that it understands all of these, and presumably an infinite number of weird edge cases: export const reset = true; const reset = true;
export { reset }; export const reset = some_value(); // export const reset = true; Otherwise it would have to be determined at runtime by loading layout components higher up the tree, executing In any case I think the filename is probably clearer insofar as you can understand the route structure by just looking at the filesystem. |
Is it true that today the way of reseting layout is via the @ at the filename on page/layouts as pointed in docs ? |
This should be mentioned on the docs page, possibly on this page: https://kit.svelte.dev/docs/advanced-routing#advanced-layouts |
Closes #626.
Before submitting the PR, please make sure you do the following
Tests
pnpm test
and lint the project withpnpm lint
Changesets
pnpx changeset
and following the prompts