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

fix: avoid using shared global state for head #916

Merged
merged 5 commits into from
Oct 30, 2023
Merged

Conversation

wattanx
Copy link
Collaborator

@wattanx wattanx commented Sep 17, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

If you use UnheadPlugin, you need to add unhead to $options.
If useHead is used without being added, a vue warn will be thrown.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe changed the title feat: new Vue2 Plugin for unhead/vue fix: use new vue 2 plugin for unhead/vue Sep 18, 2023
@harlan-zw
Copy link
Contributor

Thanks for updating it, though in what context is this thrown?

UnheadPlugin from @unhead/vue causes [Vue warn]: injection "usehead" not found., so fixed for Nuxt 2.

There's probably a better fix than copying over the plugin code.

@wattanx
Copy link
Collaborator Author

wattanx commented Sep 25, 2023

@harlan-zw
Thanks ❀️

If you use UnheadPlugin, you need to add unhead to $options.
If useHead is used without being added, a vue warn will be thrown.

https://github.com/unjs/unhead/blob/53e63ca42d8311e9690513aab8f6cff0d067b2df/packages/vue/src/vue2/index.ts#L39-L53

I tried to think of a way to add unhead to $options in the case of Nuxt, but couldn't come up with a good way.

@harlan-zw harlan-zw changed the title fix: use new vue 2 plugin for unhead/vue fix: quite head global usage warnings with injection handler Oct 29, 2023
@harlan-zw harlan-zw changed the title fix: quite head global usage warnings with injection handler fix: avoid using shared global state for head Oct 29, 2023
@harlan-zw
Copy link
Contributor

harlan-zw commented Oct 29, 2023

Hi @wattanx, sorry I couldn't get this code pushed up for your talk!

I've pushed up some changes that fix the warnings being emitted which I think is the underlying issue you may have been trying to solve? For now, I think Nuxt 2 should use the deprecated plugin as the new one has some issues within Bridge.

Would you mind reviewing and making sure I've understood correctly?

@wattanx
Copy link
Collaborator Author

wattanx commented Oct 29, 2023

No worries!

Your fixes have solved the problem I was hoping to solve!
Thank you so much ❀️

@wattanx wattanx merged commit 5c87c30 into main Oct 30, 2023
9 checks passed
@wattanx wattanx deleted the chore/update-unhead branch October 30, 2023 12:53
@github-actions github-actions bot mentioned this pull request Oct 30, 2023
@github-actions github-actions bot mentioned this pull request Nov 7, 2023
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

Successfully merging this pull request may close these issues.

2 participants