mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
refactor(nuxt): remove vue-meta
for head support (#9638)
This commit is contained in:
parent
1a6186f3a8
commit
4cb7e425a1
@ -23,7 +23,6 @@ export default defineBuildConfig({
|
||||
externals: [
|
||||
'@vue/reactivity',
|
||||
'@vue/shared',
|
||||
'@vueuse/head',
|
||||
'vue-meta'
|
||||
'@vueuse/head'
|
||||
]
|
||||
})
|
||||
|
@ -84,8 +84,7 @@
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/hash-sum": "^1.0.0",
|
||||
"unbuild": "latest",
|
||||
"vue-meta": "next"
|
||||
"unbuild": "latest"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.16.0 || ^16.10.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
|
@ -1,43 +0,0 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createMetaManager } from 'vue-meta'
|
||||
import type { MetaObject } from '..'
|
||||
import { defineNuxtPlugin } from '#app'
|
||||
// @ts-expect-error untyped
|
||||
import { appHead } from '#build/nuxt.config.mjs'
|
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
// @ts-expect-error missing resolver
|
||||
const manager = createMetaManager(process.server)
|
||||
manager.addMeta(appHead)
|
||||
|
||||
nuxtApp.vueApp.use(manager)
|
||||
|
||||
nuxtApp._useHead = (meta: MetaObject) => manager.addMeta(meta)
|
||||
|
||||
if (process.client) {
|
||||
const teleportTarget = document.createElement('div')
|
||||
teleportTarget.id = 'head-target'
|
||||
document.body.appendChild(teleportTarget)
|
||||
|
||||
createApp({ render: () => manager.render({}) }).mount('#head-target')
|
||||
}
|
||||
|
||||
if (process.server) {
|
||||
nuxtApp.ssrContext!.renderMeta = async () => {
|
||||
// @ts-ignore
|
||||
const { renderMetaToString } = await import('vue-meta/ssr')
|
||||
nuxtApp.ssrContext!.teleports = nuxtApp.ssrContext!.teleports || {}
|
||||
|
||||
await renderMetaToString(nuxtApp.app, nuxtApp.ssrContext)
|
||||
|
||||
return {
|
||||
htmlAttrs: nuxtApp.ssrContext!.teleports.htmlAttrs || '',
|
||||
headAttrs: nuxtApp.ssrContext!.teleports.headAttrs || '',
|
||||
bodyAttrs: nuxtApp.ssrContext!.teleports.bodyAttrs || '',
|
||||
headTags: nuxtApp.ssrContext!.teleports.head || '',
|
||||
bodyScriptsPrepend: nuxtApp.ssrContext!.teleports['body-prepend'] || '',
|
||||
bodyScripts: nuxtApp.ssrContext!.teleports.body || ''
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
@ -19,7 +19,6 @@ export default defineBuildConfig({
|
||||
],
|
||||
externals: [
|
||||
// Type imports
|
||||
'vue-meta',
|
||||
'vue-router',
|
||||
'vue-bundle-renderer',
|
||||
'@unhead/schema',
|
||||
|
@ -455,7 +455,6 @@ importers:
|
||||
vue: 3.2.45
|
||||
vue-bundle-renderer: ^1.0.0
|
||||
vue-devtools-stub: ^0.1.0
|
||||
vue-meta: next
|
||||
vue-router: ^4.1.6
|
||||
dependencies:
|
||||
'@nuxt/devalue': 2.0.0
|
||||
@ -506,7 +505,6 @@ importers:
|
||||
'@types/fs-extra': 9.0.13
|
||||
'@types/hash-sum': 1.0.0
|
||||
unbuild: 1.0.2
|
||||
vue-meta: 3.0.0-alpha.2_vue@3.2.45
|
||||
|
||||
packages/schema:
|
||||
specifiers:
|
||||
@ -8980,15 +8978,6 @@ packages:
|
||||
webpack: 5.75.0
|
||||
dev: false
|
||||
|
||||
/vue-meta/3.0.0-alpha.2_vue@3.2.45:
|
||||
resolution: {integrity: sha512-mLDB/vGjn2Q58IFKs5Dtp/STWZ0sEbkdM67u+YXuMreK5EjNHnqhcylQb+xn50pwxCdQD98nGgJlEXkh16Hqug==}
|
||||
peerDependencies:
|
||||
'@vue/server-renderer': ^3.0.6
|
||||
vue: ^3.0.0
|
||||
dependencies:
|
||||
vue: 3.2.45
|
||||
dev: true
|
||||
|
||||
/vue-router/4.1.6_vue@3.2.45:
|
||||
resolution: {integrity: sha512-DYWYwsG6xNPmLq/FmZn8Ip+qrhFEzA14EI12MsMgVxvHFDYvlr4NXpVF5hrRH1wVcDP8fGi5F4rxuJSl8/r+EQ==}
|
||||
peerDependencies:
|
||||
|
Loading…
Reference in New Issue
Block a user