diff --git a/apps/vdn-static/package.json b/apps/vdn-static/package.json index 456b0af..5d35406 100644 --- a/apps/vdn-static/package.json +++ b/apps/vdn-static/package.json @@ -17,7 +17,6 @@ "arktype": "^2.1.29", "axios": "^1.11.0", "bulma": "^1.0.4", - "pinia": "^3.0.4", "tailwindcss": "^4.1.6", "vue-i18n": "^11.1.3", "vue-router": "^5.0.4" diff --git a/apps/vdn-static/src/composables/useI18nMeta.ts b/apps/vdn-static/src/composables/useI18nMeta.ts index 00f7d1d..1b17e40 100644 --- a/apps/vdn-static/src/composables/useI18nMeta.ts +++ b/apps/vdn-static/src/composables/useI18nMeta.ts @@ -1,8 +1,8 @@ import { computed, type ComputedRef, type Ref, unref, watch } from 'vue' import { useRoute } from 'vue-router' -import { useMeta, type MetaConfig, type LocaleAwareMeta, type OpenGraphConfig, type TwitterCardConfig } from './useMeta' +import { useMeta, type MetaConfig, type LocaleAwareMeta } from './useMeta' import { useLocale, type LocaleId } from '../i18n' -import type { RouteMetaValue } from '../types/route-meta.d' +import type { RouteMeta, RouteMetaValue } from '../types/route-meta.d' /** * Composable for i18n-aware meta tag management @@ -49,7 +49,7 @@ export function useI18nMeta( routeValue: typeof route ): T | undefined => { if (value === undefined) return undefined - return typeof value === 'function' ? (value as Function)(routeValue) as T : value + return typeof value === 'function' ? value(routeValue) : value } /** @@ -66,8 +66,8 @@ export function useI18nMeta( keywords: resolveMetaValue(configValue.keywords, routeValue), author: resolveMetaValue(configValue.author, routeValue), canonical: resolveMetaValue(configValue.canonical, routeValue), - og: resolveI18nOgTwitter(resolveMetaValue(configValue.og, routeValue), currentLocale), - twitter: resolveI18nOgTwitter(resolveMetaValue(configValue.twitter, routeValue), currentLocale), + og: resolveMetaValue(configValue.og, routeValue), + twitter: resolveMetaValue(configValue.twitter, routeValue), custom: resolveI18nCustomTags(resolveMetaValue(configValue.custom, routeValue), currentLocale), } }) @@ -135,28 +135,6 @@ function resolveI18nContent( return content['en-US'] || Object.values(content)[0] } -/** - * Resolves locale-aware title/description fields in og/twitter config objects. - * After resolution, title/description are plain strings — compatible with MetaConfig. - */ -function resolveI18nOgTwitter( - config: I18nOpenGraphConfig | I18nTwitterCardConfig | undefined, - locale: LocaleId -): OpenGraphConfig | TwitterCardConfig | undefined { - if (!config) return config - const title = config.title - ? typeof config.title === 'object' - ? resolveI18nContent(config.title as LocaleAwareMeta, locale) - : config.title - : config.title - const description = config.description - ? typeof config.description === 'object' - ? resolveI18nContent(config.description as LocaleAwareMeta, locale) - : config.description - : config.description - return { ...config, title, description } as OpenGraphConfig | TwitterCardConfig -} - /** * Resolves custom meta tags with i18n support */ @@ -180,26 +158,14 @@ function resolveI18nCustomTags( return customTags.map(tag => ({ ...tag, - content: typeof tag.content === 'function' - ? '' - : typeof tag.content === 'object' - ? resolveI18nContent(tag.content as any, currentLocale) || '' + content: typeof tag.content === 'string' && typeof tag.content === 'object' + ? resolveI18nContent(tag.content as any, currentLocale) || '' + : typeof tag.content === 'function' + ? tag.content : tag.content })) } -/** OpenGraph config with locale-aware title/description */ -type I18nOpenGraphConfig = Omit & { - title?: string | LocaleAwareMeta - description?: string | LocaleAwareMeta -} - -/** Twitter Card config with locale-aware title/description */ -type I18nTwitterCardConfig = Omit & { - title?: string | LocaleAwareMeta - description?: string | LocaleAwareMeta -} - /** * i18n-aware meta configuration interface */ @@ -214,14 +180,12 @@ export interface I18nMetaConfig { author?: string | ((route: any) => string) /** Canonical URL */ canonical?: string | ((route: any) => string) - /** OpenGraph configuration (locale-aware title/description) */ - og?: I18nOpenGraphConfig | ((route: any) => I18nOpenGraphConfig) - /** Twitter Card configuration (locale-aware title/description) */ - twitter?: I18nTwitterCardConfig | ((route: any) => I18nTwitterCardConfig) + /** OpenGraph configuration */ + og?: MetaConfig['og'] + /** Twitter Card configuration */ + twitter?: MetaConfig['twitter'] /** Custom meta tags */ custom?: MetaConfig['custom'] - /** Robots meta directive (e.g. 'index, follow') */ - robots?: string | ((route: any) => string) /** Hreflang configuration for international SEO */ hreflang?: { [locale: string]: string diff --git a/apps/vdn-static/src/composables/useMeta.ts b/apps/vdn-static/src/composables/useMeta.ts index 89cfff9..4d5766c 100644 --- a/apps/vdn-static/src/composables/useMeta.ts +++ b/apps/vdn-static/src/composables/useMeta.ts @@ -33,8 +33,6 @@ export interface MetaConfig { appendLocale?: boolean /** Title template for formatting */ titleTemplate?: (title: string) => string - /** Robots meta directive (e.g. 'index, follow') */ - robots?: string | ((route: RouteLocationNormalizedLoaded) => string) } /** @@ -237,7 +235,7 @@ export function useMeta( routeValue: RouteLocationNormalizedLoaded ): T | undefined => { if (value === undefined) return undefined - return typeof value === 'function' ? (value as Function)(routeValue) as T : value + return typeof value === 'function' ? value(routeValue) : value } /** diff --git a/apps/vdn-static/src/composables/useRouteMeta.ts b/apps/vdn-static/src/composables/useRouteMeta.ts index d530137..2b7e3ec 100644 --- a/apps/vdn-static/src/composables/useRouteMeta.ts +++ b/apps/vdn-static/src/composables/useRouteMeta.ts @@ -1,8 +1,7 @@ import { watch, onMounted, onUnmounted, type Ref, computed, unref } from 'vue' import { useRoute } from 'vue-router' import { useMeta } from './useMeta' -import type { RouteMeta } from 'vue-router' -import type { RouteMetaValue } from '../types/route-meta' +import type { RouteMeta, RouteMetaValue, isMetaFunction } from '../types/route-meta.d' /** * Composable for automatic meta tag management based on route configuration @@ -46,7 +45,7 @@ export function useRouteMeta() { routeValue: typeof route ): T | undefined => { if (value === undefined) return undefined - return typeof value === 'function' ? (value as Function)(routeValue) as T : value + return typeof value === 'function' ? value(routeValue) : value } /** diff --git a/apps/vdn-static/src/config/meta-examples.ts b/apps/vdn-static/src/config/meta-examples.ts index 9ccd319..713fd4d 100644 --- a/apps/vdn-static/src/config/meta-examples.ts +++ b/apps/vdn-static/src/config/meta-examples.ts @@ -5,8 +5,7 @@ * in the Viossa application. */ -import type { MetaConfig } from '../composables/useMeta' -import type { I18nMetaConfig } from '../composables/useI18nMeta' +import type { MetaConfig, I18nMetaConfig } from '../composables/useI18nMeta' import { createRouteMeta } from '../composables/useMeta' /** diff --git a/apps/vdn-static/src/pages/admin/index.vue b/apps/vdn-static/src/pages/admin/index.vue index 183703e..0323773 100644 --- a/apps/vdn-static/src/pages/admin/index.vue +++ b/apps/vdn-static/src/pages/admin/index.vue @@ -1,5 +1,5 @@