mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-26 10:57:32 +00:00
24 lines
674 B
TypeScript
24 lines
674 B
TypeScript
import type { Plugin } from 'nuxt/app'
|
|
import { createHead, renderHeadToString } from '@vueuse/head'
|
|
import { Head, Html, Body, Title, Meta, Link, Script, Style } from './head'
|
|
|
|
export default <Plugin> function head (nuxt) {
|
|
const { app, ssrContext } = nuxt
|
|
const head = createHead()
|
|
|
|
app.use(head)
|
|
|
|
app.component('NuxtHead', Head)
|
|
app.component('NuxtHtml', Html)
|
|
app.component('NuxtBody', Body)
|
|
app.component('NuxtTitle', Title)
|
|
app.component('NuxtMeta', Meta)
|
|
app.component('NuxtHeadLink', Link)
|
|
app.component('NuxtScript', Script)
|
|
app.component('NuxtStyle', Style)
|
|
|
|
if (process.server) {
|
|
ssrContext.head = () => renderHeadToString(head)
|
|
}
|
|
}
|