5

If I have a main layout "+layout.svelte" at /routes and then try to reset the layout at /routes/auth/login It is not working.

  • If the name is "+layout.svelte" the layout is embedding inside the main layout.
  • If the name is "+layout@.svelte" it's not working.
  • If the name is "+layout.reset.svelte" its: Error: Files prefixed with + are reserved.

Because the default configuration of svelte/kit is vite. I think they changed it, but I don't know how to do it.

Only thing I can find in the docs about resetting layouts.

At: kit.svelte.dev/docs/advanced-routing#advanced-layouts-layout

Julian
  • 103
  • 1
  • 7
  • What do you mean by "not working"? Can you share the error messages? – Odilf Aug 30 '22 at 16:44
  • +layout@.svelte: Error: Files prefixed with + are reserved (saw src/routes/auth/+layout@.svelte) The only way I get no Error is when I use the default "+layout.svelte" name, but then it's embedding into the root layout from /src/routes/+layout.svelte – Julian Aug 31 '22 at 08:49
  • I answered the question in detail on this stackoverflow link https://stackoverflow.com/a/75472704/2950918 – Israel Ortiz Cortés Feb 16 '23 at 13:08

2 Answers2

6

Stuff has happened in the world since the accepted answer was posted. This is also true for Svelte/kit. Now there is something called (group) that looks like this:

src/routes/
│ (app)/
│ ├ dashboard/
│ ├ item/
│ └ +layout.svelte
│ (marketing)/
│ ├ about/
│ ├ testimonials/
│ └ +layout.svelte
├ admin/
└ +layout.svelte 

This lets you group layouts in directories that has its name wrapped in parenthesis (that don't affect the routing). Here a +layout.svelte file inside such a directory will add to the src/+layout.svelte file - this layout wraps all other layout files defined in grouped directories.

Once you wrap your head around it, it is very easy to use. Read more about it in the documentation for advanced routing / advanced layouts

pusle
  • 1,393
  • 14
  • 18
3

you need to create login layout at routes as +layout-login.svelte and refer on login page as +page@login.svelte

Williamz
  • 25
  • 6