withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.78k stars 2.48k forks source link

Body can't be set outside of layout #11031

Closed reggi closed 6 months ago

reggi commented 6 months ago

Astro Info

✗ npx astro info
Astro                    v4.7.0
Node                     v21.7.3
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/tailwind

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I have a series of nested layouts and I didn't want the <body> tag included in the root layout because I wanted to be able to add custom tailwind. But I realized that astro will ignore a <body> if it's as a <slot> to a layout. I think the dom is adding a body when you view the tree, but view source shows no body.

What's the expected result?

That I'd be able to set a body from outside the root layout.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-hfbtiv?file=src%2Fpages%2Findex.astro

Participation

matthewp commented 6 months ago

This has never worked very well and I would suggest not doing this. Instead make your layout include the body but pass the props you want to be attached to it.

There is a compiler bug for this already, so going to close this one as a duplicate of https://github.com/withastro/compiler/issues/982