@@ -2,7 +2,7 @@ import { useRequestHeaders, useCookie as useNuxtCookie } from '#imports'
22import { ref , computed , watch , onUnmounted } from 'vue'
33import { parseAcceptLanguage , wrapComposable , runtimeDetectBrowserLanguage } from '../internal'
44import { DEFAULT_DYNAMIC_PARAMS_KEY , localeCodes , normalizedLocales } from '#build/i18n.options.mjs'
5- import { getActiveHead } from 'unhead '
5+ import { useHead } from '#imports '
66import { initCommonComposableOptions } from '../utils'
77import {
88 creatHeadContext ,
@@ -20,7 +20,6 @@ import type { Ref } from 'vue'
2020import type { Locale } from 'vue-i18n'
2121import type { resolveRoute } from '../routing/routing'
2222import type { I18nHeadMetaInfo , I18nHeadOptions , SeoAttributesOptions } from '#internal-i18n-types'
23- import type { HeadParam } from '../utils'
2423import type { RouteLocationAsRelativeI18n , RouteLocationRaw , RouteLocationResolvedI18n , RouteMapI18n } from 'vue-router'
2524
2625export * from 'vue-i18n'
@@ -42,7 +41,7 @@ export type SetI18nParamsFunction = (params: Partial<Record<Locale, unknown>>) =
4241 */
4342export function useSetI18nParams ( seo ?: SeoAttributesOptions ) : SetI18nParamsFunction {
4443 const common = initCommonComposableOptions ( )
45- const head = getActiveHead ( )
44+ const head = useHead ( { } )
4645 const router = common . router
4746
4847 // @ts -expect-error accepts more
@@ -80,28 +79,17 @@ export function useSetI18nParams(seo?: SeoAttributesOptions): SetI18nParamsFunct
8079 }
8180
8281 const setMeta = ( ) => {
83- const metaObject : HeadParam = {
84- link : [ ] ,
85- meta : [ ]
82+ // Reset SEO Meta
83+ if ( ! ctx . locale || ! ctx . locales ) {
84+ head ?. patch ( { } )
85+ return
8686 }
8787
8888 // Adding SEO Meta
89- if ( ctx . locale && ctx . locales ) {
90- // prettier-ignore
91- metaObject . link . push (
92- ...getHreflangLinks ( common , ctx ) ,
93- ...getCanonicalLink ( common , ctx )
94- )
95-
96- // prettier-ignore
97- metaObject . meta . push (
98- ...getOgUrl ( common , ctx ) ,
99- ...getCurrentOgLocale ( ctx ) ,
100- ...getAlternateOgLocales ( ctx )
101- )
102- }
103-
104- head ?. push ( metaObject )
89+ head ?. patch ( {
90+ link : [ ...getHreflangLinks ( common , ctx ) , ...getCanonicalLink ( common , ctx ) ] ,
91+ meta : [ ...getOgUrl ( common , ctx ) , ...getCurrentOgLocale ( ctx ) , ...getAlternateOgLocales ( ctx ) ]
92+ } )
10593 }
10694
10795 return function ( params : Partial < Record < Locale , unknown > > ) {
0 commit comments