Composables

useLocaleHead

The useLocaleHead() composable returns localized head properties for locale-related aspects.

The useLocaleHead() composable returns localized head properties for locale-related aspects.

Type

declare function useLocaleHead(options: I18nHeadOptions): Ref<I18nHeadMetaInfo>

Parameters

options

An object accepting the following optional fields:

  • dir
    • type: boolean
    • default: true
    • Adds a dir attribute to the HTML element.
  • lang
    • type: boolean
    • default: true
    • Adds a lang attribute to the HTML element.
  • seo
    • type: boolean | SeoAttributesOptions
    • Adds various SEO attributes.
  • key
    • type: string
    • default: 'hid'
    • Identifier attribute of <meta> tag.

Usage

<script setup>
const i18nHead = useLocaleHead({
  seo: {
    canonicalQueries: ['foo']
  }
})
useHead({
  htmlAttrs: {
    lang: i18nHead.value.htmlAttrs!.lang
  },
  link: [...(i18nHead.value.link || [])],
  meta: [...(i18nHead.value.meta || [])]
})
</script>

Copyright © 2024