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/content
directory in.md
files.In
routes/[...slug]/+page.ts
I'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/abc
and/customers/xyz
will not only useroutes/+layout.svelte
but their specific layouts as well i.eroutes/blog/+layout.svelte
and so on.I tried putting
+layout.svelte
in bothroutes/blog/+layout.svelte
androutes/[...slug]blog/_layout.svelte
but kit does not seem to use either as the layout for/blog/something
Reproduction
Please see the steps in the Describe the bug section I can't share the repo as it is private.
System Info
Severity
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