From 5089f8375cb26a97890f2b41d51aaffb3e203a2a Mon Sep 17 00:00:00 2001 From: Bobbie Goede Date: Mon, 30 Sep 2024 13:58:17 +0200 Subject: [PATCH] fix: warn if seo features are used without `baseUrl` --- src/runtime/composables/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/runtime/composables/index.ts b/src/runtime/composables/index.ts index 2124fefc0..c3e815cf8 100644 --- a/src/runtime/composables/index.ts +++ b/src/runtime/composables/index.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { useRequestHeaders, useCookie as useNuxtCookie } from '#imports' -import { ref, computed, watch, onUnmounted } from 'vue' +import { ref, computed, watch, onUnmounted, unref } from 'vue' import { parseAcceptLanguage, wrapComposable, runtimeDetectBrowserLanguage } from '../internal' import { DEFAULT_DYNAMIC_PARAMS_KEY, localeCodes, normalizedLocales } from '#build/i18n.options.mjs' import { getActiveHead } from 'unhead' @@ -80,6 +80,10 @@ export function useSetI18nParams(seo?: SeoAttributesOptions): SetI18nParamsFunct const currentLocale = getNormalizedLocales(locales).find(l => l.code === locale) || { code: locale } const currentLocaleLanguage = currentLocale.language + if (!unref(i18n.baseUrl)) { + console.warn('I18n `baseUrl` is required to generate valid SEO tag links.') + } + const setMeta = () => { const metaObject: HeadParam = { link: [],