-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Support removing tags generated outside of Unhead #232
Comments
What about an option in the initialization (
Anyway, maybe I'm missing an entirely different reason that this is complicated, and just answering the "simple" part of the question. By way of information, I currently address this shortcoming by doing something like:
Which of course doesn't REMOVE the tag, but does create one with empty content, which appears to work for this particular tag. Obviously this solution doesn't really work for other tags, but for me, it saves me from having to write a client-side removal outside of the unhead routine. |
Thank you for the idea! Will think about this more, it's definitely something that will be solved at some point. |
I have resolved this by using a custom unhead plugin. () => ({
hooks: {
init(ctx) {
const descriptionEl = document.querySelector('meta[name="description"]')
if (!descriptionEl)
return
ctx.push({
meta: [
{
name: 'description',
content: descriptionEl.getAttribute('content'),
},
],
})
descriptionEl.remove()
},
},
}), |
Describe the feature
Due to how the DOM rendered logic is set up, it's not currently possible to remove tags that Unhead itself didn't create OR if Unhead did make the tags, but only in a server context (without hydration).
Related #179 (comment),
For example, in the below, we want to remove the meta tag.
To remove the above would require some tricky client-side unhead usage, we would need to essentially mock hydrating these tags and then remove them AFTER they've been hydrated.
Fixing this will require rearchitecting the "side-effect" paradigm of the DOM renderer or adding in logic that can handle these removals if they're not synced.
I think we should target the v2 as the candidate for this as it will be dangerous.
Additional information
The text was updated successfully, but these errors were encountered: