mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-15 10:24:50 +00:00
18 lines
675 B
TypeScript
18 lines
675 B
TypeScript
import { isFunction } from '@vue/shared'
|
|
import { computed } from '@vue/reactivity'
|
|
import type { ComputedGetter } from '@vue/reactivity'
|
|
import type { MetaObject } from '../types'
|
|
import { useNuxt } from '#app'
|
|
|
|
/**
|
|
* You can pass in a meta object, which has keys corresponding to meta tags:
|
|
* `title`, `base`, `script`, `style`, `meta` and `link`, as well as `htmlAttrs` and `bodyAttrs`.
|
|
*
|
|
* Alternatively, for reactive meta state, you can pass in a function
|
|
* that returns a meta object.
|
|
*/
|
|
export function useMeta (meta: MetaObject | ComputedGetter<MetaObject>) {
|
|
const resolvedMeta = isFunction(meta) ? computed(meta) : meta
|
|
useNuxt()._useMeta(resolvedMeta)
|
|
}
|