Skip to content
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

Multiple slots in +layout.svelte #11921

Closed
cowboycodr opened this issue Feb 29, 2024 · 3 comments
Closed

Multiple slots in +layout.svelte #11921

cowboycodr opened this issue Feb 29, 2024 · 3 comments

Comments

@cowboycodr
Copy link

Describe the problem

Recently, I've had to extract my +layout.svelte page into a separate component that I use in my +page.svelte. While this solution is a good workaround, it makes it extremely difficult to utilize Svelte's SSR without causing a complete refresh on separate pages that share the same server data.

Describe the proposed solution

Allow users to define +layout.svelte with multiple slots, the same way components do.

<script>
     // src/routes/+layout.svelte
</script>

<main>
     <slot />
</main>

<aside>
    <slot name="aside" />
</aside>

Alternatives considered

You can define your own layout component that you utilize in each one of your pages. However, hard to implement without slowing down your site. Would be much easier to do the proposed solution.

Importance

would make my life easier

Additional Information

No response

@Conduitry
Copy link
Member

What would determine what gets loaded into that slot?

@cowboycodr
Copy link
Author

In theory it would work the same way it does for components. Using the "slot" attribute.

+page.svelte

<script>
    ...
</script>

<p>This content here is going inside of the parent's main tag.</p>

<p slot="aside">However, this content is going inside the parent's aside tag</p>

@geoffrich
Copy link
Member

Duplicate of #627

@geoffrich geoffrich marked this as a duplicate of #627 Feb 29, 2024
@geoffrich geoffrich closed this as not planned Won't fix, can't repro, duplicate, stale Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants