-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Introducing @nuxt/vue-app-head
to replace vue-meta.
Issues of vue-meta
1.0
vue-meta
is created by Declan Dewet who cannot maintain this project anymore, I took over 2 years ago after helping him so I could maintain it for Nuxt.The Nuxt team has no push access for itWe now have!- Depends on deepmerge, lodash.isplainobject and object-assign (this will change in a future vue-meta version)
- 3,6Kb gzip just to support head elements (https://bundlephobia.com/[email protected]), I think we can do better if we focus on Nuxt integration
vue-meta 2.0
Will be simply a refactor of the actual one with optimisations and bug fixes.
vue-meta 3.0
vue-meta
is the default package used by @nuxt/vue-app
but it could be disabled by another module (introducing the way to work with hooks
with these external modules).
I believe we could introduce a new component: <n-head>
Example (pages/users/[userId].vue
):
<template>
<div>
<n-head>
<title>{{ user.name }}</title>
<meta key="description" name="description" :content="user.description">
</n-head>
<pre>{{ user }}</pre>
</div>
</template>
<script>
export default {
async asyncData({ $axios, params }) {
const user = await $axios.$get(`https://.../api/users/${params.userId}`)
return { user }
}
}
</script>
The point of this component is simply a shortcut to write inside the head
key (we should keep this key to let librairies like Vuetify
add mixins for it when used with Nuxt).
Here, key
is simply the vmid
we have in head
, I believe by using a functional component, we could achieve easily this behaviour.
This <n-head>
should have some props to handle body-attrs
and html-attrs
, about head-attrs
, well, it's all the others non-defined props directly :)
What do you think?