-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
🐛 BUG: Collection of <head>
issues as of v0.21.10
#2128
Comments
Thank you! This is a very thorough and helpful overview. |
Thank you!! This will be super useful as we work on implementing withastro/roadmap#26. We can make sure that all of these are handled before we mark that work as done. One thing that stands out as maybe not possible in the new head RFC is |
I'm very glad this helps! As briefly touched above, I did not expect
I don't know astro's internals, but would hope this would work. Since I want to mention that of course I'd be happy to help testing, and documenting the post-RFC |
Actually, if I argue that |
Please let me know if I should move these comments to the RFC. |
@philipp-tailor would love your help implementing if you can make time! Would love to pair you with someone on the core team to help tackle together. Would love your comments on the RFC itself, we'll actually be doing our weekly RFC call on Discord ~2 hours from now, and you could leave feedback there as well.
|
@FredKSchott Thanks, I joined the call, and the RFC makes sense given that the head coalescing has been removed from scope on purpose. I'd be open to helping to implement, if you point me someone's way (or vice-versa). |
Sorry that this has dragged a bit, everyone! Just to give an update, this is on track to be fixed in withastro/compiler#267 and the subsequent |
Thanks so much @natemoo-re! I assume the "final" expected head behaviors will be in the documentation of |
This class of issue should definitely be fixed in Some of these examples expect some sort of "head collapsing" behavior, which is still not something that Astro supports. But you should be able to use
See https://stackblitz.com/edit/github-accdiv-pum797?file=src%2Fpages%2Findex.astro and https://stackblitz.com/edit/github-accdiv-nyt1bq?file=src%2Flayouts%2FBaseLayout.astro |
Per my comment above, most of these should be fixed in the newly released Please feel free to open a new issue for any problems you run into. |
What version of
astro
are you using?0.21.10
Describe the Bug
I am aware about the head RFC, and the linked GitHub issues. I still felt that a complete overview over current behaviors is missing for people dealing with
<head/>
related issues.These variations below are my most relevant attempts to create a structure to manage composite, dynamic head content in a project with nested layouts. Some of the variations - in my opinion - should work. Others of them I didn't expect to work, and they indeed did not. But that none of them work is a deal breaker for my use-cases. Behaviors changed in a breaking manner from
v0.20.x
tov0.21.x
without mention in the changelog, but it appeared to me that they even changed between differentv0.21.x
patch versions (I might be wrong about that). The variations of unexpected / non-working behaviors described below reflect the state as ofv0.21.10
.With this issue I hope to raise awareness for (potential) users of astro, and show up variations of possible cases the RFC, astro, and the test suite could cover. This overview is probably incomplete - feel free to document more behaviors as you detect them below.
1. Head cant't be complemented with content passed in fragment to slot in head
Expected:
Actual:
2. Head cant't be complemented with head element passed to slot in head
This is a variation of
1.
, which doesn't make much sense if astro is to mirror HTML, since there can only be one head in the HTML output. However, I hoped it might lead the compiler to detect that the content passed to the head slot shall be attached to the head. It doesn't, and instead behaves the same as1.
.Expected:
Actual:
3. Head content is rendered in body when head is set as default slot content
I am not sure if this is a variation of this issue?
Expected:
Actual:
4. Head can't be set when passed as slot
This expands upon
3.
, and I include it to show what I expected to happen if content is passed to the head slot.Expected:
Actual:
5. Multiple heads rendered in different layouts are not compositing
Again, a case that does not make sense from HTML perspective, but in depsparation, I tried whether it would work nevertheless.
Expected:
Actual:
6. Head can't be included only by rendering component rendering head
This one has already been reported. The code below does not use nested layouts, and does not have dynamic parts to it. That this simple case does not work, excludes all application structures where different layouts render
<BaseHead.astro
with dynamic head content passed to the slots.Expected:
Actual:
7. Head set from svelte components hydrated on client load is not part of build output
Another, advanced case that does not work, is including content from svelte components with
<svelte:head>
in the static build output. I assume that it's extremely difficult for astro to detect if a svelte component is always rendered and hydrated in a layout withclient:load
, and always limited to only being changed from the svelte component when its bundled JS is being executed?Expected:
Actual:
The head then changes once
BaseHead.svelte
is hyrated on the client.The text was updated successfully, but these errors were encountered: