-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(head): inject <script>
in rendered HTML when ssr: false
#5553
Conversation
* module adds config to nitro * module renders meta with useHead * spa renderer adds header * basic test for this feature
β Deploy Preview for nuxt3-docs canceled.
|
Thank you for the PR, indeed this is a feature we are missing from Nuxt 2. I will let @pi0 and @danielroe check about the implementation details if there is not a better way than hooking into Also something I would like to explore later if the ability to render an "App shell" or rendering |
Thanks for the initial work on this PR @JulianMar. Indeed this is what we have to reintroduce for Nuxt 3 to have the ability to add rendered meta tags and probably more hooking to customize the shell. But not adding them from the build context (module) and using a nitro plugin to inject (It works for Something else I would like to have alongside this new feature is to decouple head implementation from vue. We don't really need a vue instance to render head objects and this can help save bundle size (when moving to render logic to the runtime) and we are already thinking to do that. I think it worth waiting for it before moving forward with this feature :) (With nuxt/nuxt#14182, we can actually have a custom module making same effect of this PR in the meantime) |
Thanks for the review! It would make sense to wait for the two hooks as they would make it way easier to add this functionality. It was kinda hard to find the "correct" way to do this right now and it didn't feel correct either. You want to decouple the head implementation from vue. Does that mean you just want to remove the plugins and do most of it server side or just don't attach it to the nuxt instance? I am just curious about how this will work together, and I am not that deep in nuxt yet :D I will keep an eye on the issue for any discussions and thanks again for your awesome work with nuxt 3! |
The idea is to split |
Hi @JulianMar. I've added a quick workaround here nuxt/nuxt#14172. I've to close PR since is stalled but will do my best to deliver unjs util ASAP making it easier for integration. In the meantime, you can create it using a nitro plugin (please ping if need help on how) And once again, thanks for contributing to Nuxt <3 |
π Linked issue
nuxt/nuxt#14172
β Type of change
π Description
Add global Header to prerenderd HTML on spa mode.
This is just a first draft, so I would welcome some feedback. For example how to better handle the creation of the meta object, as I have seen there are two libraries for generating the meta object.
Resolves nuxt/nuxt#14172
π Checklist