import { Locale } from '@i18n-micro/types'; import { Plugin as Plugin_2 } from 'vite'; import { PluralFunc } from '@i18n-micro/types'; import { Translations } from '@i18n-micro/types'; import { VueI18nOptions } from '@i18n-micro/vue'; /** * Build i18n SEO head for VitePress — same tags as Nuxt `useLocaleHead` / * plugin `02.meta` (canonical, hreflang, x-default, og:locale / og:url / alternates). * * Framework-agnostic pure function; wired automatically by `withI18n` when `meta` is on. */ export declare function buildVitePressLocaleHead(options: BuildVitePressLocaleHeadOptions): VitePressLocaleHeadObject; export declare interface BuildVitePressLocaleHeadOptions { /** * Current page path (with or without `site.base`). Query/hash optional. * Example: `/docs/fr/guide/` or `/fr/guide`. */ path: string; locales: Locale[]; defaultLocale: string; localeKeyToCode?: Record; /** VitePress `site.base` (e.g. `/docs/`). */ base?: string; /** * Public site origin **without** trailing slash (e.g. `https://example.com`). * Required for absolute `canonical` / `hreflang` / `og:url`. * When omitted, only `htmlAttrs` are produced. */ metaBaseUrl?: string; /** @default false — same as Nuxt / Vue `useLocaleHead`. */ hreflangBaseLanguage?: boolean; /** Query keys kept on canonical / alternate URLs. @default [] */ canonicalQueryWhitelist?: string[]; /** @default true */ addDirAttribute?: boolean; /** @default true */ addSeoAttributes?: boolean; /** @default 'id' */ identifierAttribute?: string; missingWarn?: boolean; } /** * Build VitePress `config.locales` from i18n-micro `Locale[]`. * Default locale becomes `root` (no URL prefix); others get `/{key}/`. */ export declare function buildVitePressLocales(locales: Locale[], defaultLocale: string, options?: BuildVitePressLocalesOptions): Record; export declare interface BuildVitePressLocalesOptions { /** * Map VitePress locale keys → i18n codes (`root` → default). * When a non-default code maps to a short VP key (`fr` → `fr-FR`), the URL * prefix / config key uses the VP key. */ localeKeyToCode?: Record; } declare interface CreateI18nOptions { locale: string; fallbackLocale?: string; locales?: Locale[]; defaultLocale?: string; messages?: Record; /** * Page-scoped dictionaries keyed by route name (`guide-demo`), then locale. * Loaded from `locales/pages/**` when using `withI18n`. */ routeMessages?: Record>; plural?: PluralFunc; missingWarn?: boolean; numberFormats?: VueI18nOptions['numberFormats']; datetimeFormats?: VueI18nOptions['datetimeFormats']; timeZone?: string; missingHandler?: (locale: string, key: string, routeName: string) => void; /** * Sync i18n locale from the VitePress URL path on every navigation. * @default true */ syncWithVitePress?: boolean; /** * Map VitePress locale keys to i18n codes (`root` → default locale code). */ localeKeyToCode?: Record; /** * VitePress `site.base`. Needed so SSG paths (`withBase`) and lang switcher * do not treat the base segment as content / double-prefix links. */ base?: string; } /** * Convert VitePress `pageData.relativePath` to a route path (cleanUrls-style). */ export declare function relativePathToRoutePath(relativePath: string): string; export declare interface VirtualI18nConfig { defaultLocale: string; fallbackLocale: string; locales: Locale[]; localeCodes: string[]; missingWarn: boolean; syncWithVitePress: boolean; translationDir: string; disablePageLocales: boolean; localeKeyToCode: Record; /** VitePress `site.base` (normalized, trailing slash preserved from config). */ base?: string; numberFormats?: CreateI18nOptions['numberFormats']; datetimeFormats?: CreateI18nOptions['datetimeFormats']; timeZone?: string; } /** VitePress `HeadConfig` tuple (tag + attrs). */ export declare type VitePressHeadTuple = [string, Record]; /** * Minimal VitePress `locales` entry used by the default theme language menu. */ export declare interface VitePressLocaleEntry { label: string; lang: string; link?: string; } export declare interface VitePressLocaleHeadObject { htmlAttrs: { lang?: string; dir?: 'ltr' | 'rtl' | 'auto'; }; /** Ready for `transformHead` / `frontmatter.head`. */ head: VitePressHeadTuple[]; } /** * Minimal VitePress / Vite user config shape we merge into. * Avoid importing `vitepress` types so the package stays usable as a pure library dep. */ export declare interface VitePressUserConfigLike { base?: string; locales?: Record; themeConfig?: Record | null; transformHead?: (...args: any[]) => any; transformPageData?: (...args: any[]) => any; vite?: { plugins?: Plugin_2[] | Plugin_2[][]; ssr?: { noExternal?: string | true | Array; [key: string]: unknown; }; [key: string]: unknown; }; [key: string]: unknown; } export declare function warnLocaleMismatch(config: VitePressUserConfigLike, options: WithI18nOptions): void; /** * VitePress config helper: virtual modules + optional `i18nRouting` / SEO head. * * Registers: * - `virtual:i18n-micro/config` * - `virtual:i18n-micro/messages` (from `translationDir`, default `locales/`) * * By default also sets `themeConfig.i18nRouting` (pass `i18nRouting: false` to skip). * Pair with `defineI18nTheme(DefaultTheme)` from `@i18n-micro/vitepress/theme`. * Import from `@i18n-micro/vitepress/config` (Node / config files only). */ export declare function withI18n(config: T, options: WithI18nOptions): T; export declare interface WithI18nOptions extends CreateI18nOptions { /** * Directory with locale JSON (`en.json`, `pages/guide/demo/en.json`, …), relative to Vite root * (VitePress content / docs root). Used by `virtual:i18n-micro/messages`. * @default 'locales' */ translationDir?: string; /** * When true, treat `pages/**` as root-level dictionaries. * @default false */ disablePageLocales?: boolean; /** * When true, logs a warning if VitePress `locales` keys do not align with * configured i18n locale codes. * @default true */ warnOnLocaleMismatch?: boolean; /** * Inject `themeConfig.i18nRouting` from adapter options + `config.base`. * Set `false` to skip. Skipped automatically when `themeConfig.i18nRouting` is already set. * @default true */ i18nRouting?: boolean; /** * Emit i18n SEO tags via `transformHead` (canonical, hreflang, og:locale…) — * Nuxt `meta` / plugin `02.meta` analogue. * Absolute link tags require `metaBaseUrl`. * @default true when `metaBaseUrl` is set, otherwise false */ meta?: boolean; /** * Public origin without trailing slash (`https://example.com`). * Same role as Nuxt `metaBaseUrl`. */ metaBaseUrl?: string; /** Also emit bare-language hreflang from `iso` (Nuxt `hreflangBaseLanguage`). @default false */ hreflangBaseLanguage?: boolean; /** Query keys kept on canonical / alternate URLs. @default [] */ canonicalQueryWhitelist?: string[]; } export { }