nested layouts don't work for routes using [...rest] parameters structure. #9069
Replies: 2 comments 4 replies
-
| 
         Someone at the Svelte discord told me that I could do something like: and then abstract what I have in  we are gonna have many different page types. It would be great if kit adds support for it.  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         I converted this to a discussion because it's not a bug and there's also no feature request which we can act on. I suggest to do either what was suggested on Discord (it's only the files you need to duplicate, you can create a common Svelte and load file from which you just import the things you need), or the following: Inside your  <script>
  import { page } from '$app/stores';
  $: category = $page.params?.split('/')[0];
</script>
<div>
  <h2>Main layout stuff</h2>
  {#if category === 'blog'}
     <h3>Category layout stuff</h3>
     <slot />
  {:else if category === ...
</div> | 
  
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
We are looking to migrate our site from Next JS to Sveltekit.
In the routes directory, I have the following:
We're using a visual CMS that requires us to have the pages in the

src/contentdirectory in.mdfiles.In
routes/[...slug]/+page.tsI'm importing all the markdown files and then returning the correct page data based on the slug parameter.We want to use different layouts for different routes i.e
/blog/something,/guides/abcand/customers/xyzwill not only useroutes/+layout.sveltebut their specific layouts as well i.eroutes/blog/+layout.svelteand so on.I tried putting
+layout.sveltein bothroutes/blog/+layout.svelteandroutes/[...slug]blog/_layout.sveltebut kit does not seem to use either as the layout for/blog/somethingReproduction
Please see the steps in the Describe the bug section I can't share the repo as it is private.
System Info
System: OS: macOS 12.3 CPU: (10) arm64 Apple M1 Max Memory: 2.81 GB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm Browsers: Chrome: 110.0.5481.100 Firefox: 109.0.1 Safari: 15.4 npmPackages: @sveltejs/adapter-auto: ^1.0.0 => 1.0.2 @sveltejs/adapter-static: ^1.0.6 => 1.0.6 @sveltejs/kit: ^1.5.2 => 1.5.2 svelte: ^3.54.0 => 3.55.1 vite: ^4.0.0 => 4.1.1Severity
We can get around this as specified here #9068 (comment) but the developer experience is not gonna be in line with entire Svelte and Kit ecosystem DX.
Beta Was this translation helpful? Give feedback.
All reactions