@fluenti/nuxt 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/detectors-BnmzZTww.cjs +2 -0
- package/dist/detectors-BnmzZTww.cjs.map +1 -0
- package/dist/detectors-CAqp_VCN.js +100 -0
- package/dist/detectors-CAqp_VCN.js.map +1 -0
- package/dist/devtools.d.ts +31 -0
- package/dist/devtools.d.ts.map +1 -0
- package/dist/isr-validation.d.ts +14 -0
- package/dist/isr-validation.d.ts.map +1 -0
- package/dist/locale-head-BuSO-fCZ.js +88 -0
- package/dist/locale-head-BuSO-fCZ.js.map +1 -0
- package/dist/locale-head-D1NAUQc8.cjs +2 -0
- package/dist/locale-head-D1NAUQc8.cjs.map +1 -0
- package/dist/module.cjs +1 -1
- package/dist/module.cjs.map +1 -1
- package/dist/module.d.ts +18 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +231 -46
- package/dist/module.js.map +1 -1
- package/dist/page-extend-BrPO2RhM.js +36 -0
- package/dist/page-extend-BrPO2RhM.js.map +1 -0
- package/dist/page-extend-tRXsujtK.cjs +2 -0
- package/dist/page-extend-tRXsujtK.cjs.map +1 -0
- package/dist/page-meta-transform.d.ts +17 -0
- package/dist/page-meta-transform.d.ts.map +1 -0
- package/dist/runtime/client.cjs +1 -1
- package/dist/runtime/client.cjs.map +1 -1
- package/dist/runtime/client.js +2 -2
- package/dist/runtime/components/NuxtLinkLocale.cjs +1 -1
- package/dist/runtime/components/NuxtLinkLocale.cjs.map +1 -1
- package/dist/runtime/composables.cjs +1 -1
- package/dist/runtime/composables.cjs.map +1 -1
- package/dist/runtime/composables.d.ts +46 -0
- package/dist/runtime/composables.d.ts.map +1 -1
- package/dist/runtime/composables.js +55 -13
- package/dist/runtime/composables.js.map +1 -1
- package/dist/runtime/define-i18n-route.cjs +2 -0
- package/dist/runtime/define-i18n-route.cjs.map +1 -0
- package/dist/runtime/define-i18n-route.d.ts +27 -0
- package/dist/runtime/define-i18n-route.d.ts.map +1 -0
- package/dist/runtime/define-i18n-route.js +6 -0
- package/dist/runtime/define-i18n-route.js.map +1 -0
- package/dist/runtime/detectors/cookie.d.ts.map +1 -1
- package/dist/runtime/detectors/domain.cjs +2 -0
- package/dist/runtime/detectors/domain.cjs.map +1 -0
- package/dist/runtime/detectors/domain.d.ts +9 -0
- package/dist/runtime/detectors/domain.d.ts.map +1 -0
- package/dist/runtime/detectors/domain.js +15 -0
- package/dist/runtime/detectors/domain.js.map +1 -0
- package/dist/runtime/detectors/header.d.ts.map +1 -1
- package/dist/runtime/detectors/index.d.ts +1 -1
- package/dist/runtime/detectors/index.d.ts.map +1 -1
- package/dist/runtime/detectors/query.d.ts.map +1 -1
- package/dist/runtime/index.cjs +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -5
- package/dist/runtime/locale-head.d.ts +3 -0
- package/dist/runtime/locale-head.d.ts.map +1 -1
- package/dist/runtime/middleware/locale-redirect.cjs +1 -1
- package/dist/runtime/middleware/locale-redirect.cjs.map +1 -1
- package/dist/runtime/middleware/locale-redirect.js +1 -1
- package/dist/runtime/page-extend.d.ts +21 -5
- package/dist/runtime/page-extend.d.ts.map +1 -1
- package/dist/runtime/plugin.cjs +1 -1
- package/dist/runtime/plugin.cjs.map +1 -1
- package/dist/runtime/plugin.d.ts.map +1 -1
- package/dist/runtime/plugin.js +55 -23
- package/dist/runtime/plugin.js.map +1 -1
- package/dist/runtime/server/locale-redirect.cjs +2 -0
- package/dist/runtime/server/locale-redirect.cjs.map +1 -0
- package/dist/runtime/server/locale-redirect.d.ts +12 -0
- package/dist/runtime/server/locale-redirect.d.ts.map +1 -0
- package/dist/runtime/server/locale-redirect.js +51 -0
- package/dist/runtime/server/locale-redirect.js.map +1 -0
- package/dist/runtime/standalone-composables.cjs +2 -0
- package/dist/runtime/standalone-composables.cjs.map +1 -0
- package/dist/runtime/standalone-composables.d.ts +6 -0
- package/dist/runtime/standalone-composables.d.ts.map +1 -1
- package/dist/runtime/standalone-composables.js +34 -0
- package/dist/runtime/standalone-composables.js.map +1 -0
- package/dist/sitemap.d.ts +24 -0
- package/dist/sitemap.d.ts.map +1 -0
- package/dist/types.d.ts +210 -13
- package/dist/types.d.ts.map +1 -1
- package/llms-full.txt +411 -0
- package/llms-migration.txt +201 -0
- package/llms.txt +103 -0
- package/package.json +5 -4
- package/dist/detectors-CFJvuwzi.cjs +0 -2
- package/dist/detectors-CFJvuwzi.cjs.map +0 -1
- package/dist/detectors-DhkfHBHr.js +0 -84
- package/dist/detectors-DhkfHBHr.js.map +0 -1
- package/dist/locale-head-BfsESdd7.cjs +0 -2
- package/dist/locale-head-BfsESdd7.cjs.map +0 -1
- package/dist/locale-head-CqUlvy3O.js +0 -38
- package/dist/locale-head-CqUlvy3O.js.map +0 -1
- package/dist/page-extend-DJ7wpuVj.js +0 -25
- package/dist/page-extend-DJ7wpuVj.js.map +0 -1
- package/dist/page-extend-OvV-ZhFB.cjs +0 -2
- package/dist/page-extend-OvV-ZhFB.cjs.map +0 -1
package/llms.txt
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# @fluenti/nuxt
|
|
2
|
+
|
|
3
|
+
> Nuxt 3 module for Fluenti — locale-prefixed routing, locale detection, SEO head helpers, and NuxtLinkLocale component.
|
|
4
|
+
|
|
5
|
+
@fluenti/nuxt integrates Fluenti i18n into Nuxt 3 with four routing strategies, an ordered locale detection chain, automatic vite-plugin registration, and SSR/SSG/SPA/ISR support.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @fluenti/nuxt @fluenti/core @fluenti/vue
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// nuxt.config.ts
|
|
17
|
+
export default defineNuxtConfig({
|
|
18
|
+
modules: ['@fluenti/nuxt'],
|
|
19
|
+
fluenti: {
|
|
20
|
+
locales: ['en', 'ja', 'zh'],
|
|
21
|
+
defaultLocale: 'en',
|
|
22
|
+
strategy: 'prefix_except_default',
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Module Options
|
|
28
|
+
|
|
29
|
+
| Option | Type | Default | Description |
|
|
30
|
+
|--------|------|---------|-------------|
|
|
31
|
+
| `locales` | `string[]` | — | Supported locale codes (required) |
|
|
32
|
+
| `defaultLocale` | `string` | `'en'` | Default locale (required) |
|
|
33
|
+
| `strategy` | `Strategy` | `'prefix_except_default'` | URL routing strategy |
|
|
34
|
+
| `detectOrder` | `string[]` | `['path','cookie','header']` | Ordered locale detectors |
|
|
35
|
+
| `detectBrowserLanguage` | `object` | — | Cookie and fallback settings |
|
|
36
|
+
| `autoVitePlugin` | `boolean` | `true` | Auto-register vite-plugin |
|
|
37
|
+
| `componentPrefix` | `string` | `''` | Prefix for i18n components |
|
|
38
|
+
| `isr` | `{ enabled, ttl? }` | — | ISR route rules generation |
|
|
39
|
+
| `compat` | `boolean` | `false` | vue-i18n bridge mode |
|
|
40
|
+
|
|
41
|
+
## Routing Strategies
|
|
42
|
+
|
|
43
|
+
| Strategy | Default locale | Other locales |
|
|
44
|
+
|----------|---------------|---------------|
|
|
45
|
+
| `prefix_except_default` | `/about` | `/ja/about` |
|
|
46
|
+
| `prefix` | `/en/about` | `/ja/about` |
|
|
47
|
+
| `prefix_and_default` | `/about` + `/en/about` | `/ja/about` |
|
|
48
|
+
| `no_prefix` | `/about` | `/about` |
|
|
49
|
+
|
|
50
|
+
## Locale Detection
|
|
51
|
+
|
|
52
|
+
Detection chain runs in order: path -> cookie -> header -> fallback. First match wins. Custom detectors via `fluenti:detect-locale` hook.
|
|
53
|
+
|
|
54
|
+
## Preferred Usage (compile-time first)
|
|
55
|
+
|
|
56
|
+
1. `v-t` directive — `<p v-t>Hello {name}</p>` (Vue templates, zero runtime cost)
|
|
57
|
+
2. t\`\` tagged template — t\`Hello {name}\` (primary compile-time API)
|
|
58
|
+
3. `<Trans>` / `<Plural>` / `<Select>` — rich text with inline markup
|
|
59
|
+
4. `msg` tagged template — outside components (route meta, stores)
|
|
60
|
+
5. `useI18n().t()` — runtime fallback for dynamic keys only
|
|
61
|
+
|
|
62
|
+
❌ AVOID: `t('some.key')` as the default — this is a legacy i18n pattern.
|
|
63
|
+
|
|
64
|
+
## Auto-imported APIs
|
|
65
|
+
|
|
66
|
+
| API | Source |
|
|
67
|
+
|-----|--------|
|
|
68
|
+
| `useI18n()` | `@fluenti/vue` |
|
|
69
|
+
| `useLocalePath()` | `@fluenti/nuxt` |
|
|
70
|
+
| `useSwitchLocalePath()` | `@fluenti/nuxt` |
|
|
71
|
+
| `useLocaleHead()` | `@fluenti/nuxt` |
|
|
72
|
+
| `<NuxtLinkLocale>` | `@fluenti/nuxt` |
|
|
73
|
+
| `useLocaleRoute()` | `@fluenti/nuxt` |
|
|
74
|
+
| `defineI18nRoute(config)` | `@fluenti/nuxt` |
|
|
75
|
+
|
|
76
|
+
## Route Utilities
|
|
77
|
+
|
|
78
|
+
- `localePath(path, locale, defaultLocale, strategy)` — Add locale prefix
|
|
79
|
+
- `switchLocalePath(path, targetLocale, locales, defaultLocale, strategy)` — Switch locale in path
|
|
80
|
+
- `extractLocaleFromPath(path, locales)` — Extract locale from path
|
|
81
|
+
- `extendPages(pages, options)` — Extend Nuxt pages with locale variants
|
|
82
|
+
|
|
83
|
+
## SEO & Sitemap
|
|
84
|
+
|
|
85
|
+
- `buildLocaleHead(locale, path, config, options?)` — Generate locale-aware HTML head metadata (lang, dir, hreflang, og:locale, canonical)
|
|
86
|
+
- `generateSitemapUrls(paths, locales, defaultLocale, strategy, baseUrl?)` — Generate multi-locale sitemap entries with hreflang alternatives
|
|
87
|
+
- `createSitemapHook(locales, defaultLocale, strategy, baseUrl?)` — Hook handler for `@nuxtjs/sitemap`'s `sitemap:generate` hook
|
|
88
|
+
|
|
89
|
+
## Key Types
|
|
90
|
+
|
|
91
|
+
- `Strategy` — `'prefix' | 'prefix_except_default' | 'prefix_and_default' | 'no_prefix' | 'domains'`
|
|
92
|
+
- `FluentNuxtRuntimeConfig` — Runtime config injected into Nuxt's public runtimeConfig
|
|
93
|
+
- `DetectBrowserLanguageOptions` — Cookie and fallback settings for browser language detection
|
|
94
|
+
- `ISROptions` — ISR route rules configuration (`enabled`, `ttl?`)
|
|
95
|
+
- `DomainConfig` — Domain-to-locale mapping for the `'domains'` strategy
|
|
96
|
+
- `I18nRouteConfig` — Per-page locale restriction (`{ locales: string[] } | false`)
|
|
97
|
+
- `LocaleHeadMeta`, `LocaleHeadOptions` — Locale-aware HTML head metadata types
|
|
98
|
+
|
|
99
|
+
## Documentation
|
|
100
|
+
|
|
101
|
+
- Full docs: https://fluenti.dev
|
|
102
|
+
- llms-full.txt: Detailed reference with examples and advanced configuration
|
|
103
|
+
- Source: https://github.com/usefluenti/fluenti
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluenti/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Nuxt module for Fluenti — locale-prefixed routes, SEO helpers, auto locale detection",
|
|
6
6
|
"homepage": "https://fluenti.dev",
|
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"files": [
|
|
64
|
-
"dist"
|
|
64
|
+
"dist",
|
|
65
|
+
"llms*.txt"
|
|
65
66
|
],
|
|
66
67
|
"peerDependencies": {
|
|
67
68
|
"nuxt": "^3.0.0"
|
|
@@ -69,8 +70,8 @@
|
|
|
69
70
|
"dependencies": {
|
|
70
71
|
"@nuxt/kit": "^3.0.0",
|
|
71
72
|
"@nuxt/schema": "^3.0.0",
|
|
72
|
-
"@fluenti/core": "0.
|
|
73
|
-
"@fluenti/vue": "0.
|
|
73
|
+
"@fluenti/core": "0.3.0",
|
|
74
|
+
"@fluenti/vue": "0.3.0"
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
77
|
"typescript": "^5.9",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require(`./path-utils-BQIsp_or.cjs`);let t=require(`#imports`);function n(t){if(t.strategy===`no_prefix`)return;let{locale:n}=e.t(t.path,t.locales);n&&t.setLocale(n)}function r(e){if(!e.detectBrowserLanguage?.useCookie)return;let n=e.detectBrowserLanguage.cookieKey??`fluenti_locale`;try{let r=(0,t.useCookie)(n);r.value&&e.locales.includes(r.value)&&e.setLocale(r.value)}catch{}}function i(e){if(e.isServer)try{let n=(0,t.useRequestHeaders)([`accept-language`])[`accept-language`];if(n){let t=a(n,e.locales);t&&e.setLocale(t)}}catch{}}function a(e,t){let n=e.split(`,`).map(e=>{let[t,n]=e.trim().split(`;q=`);return{lang:t.trim().toLowerCase(),q:n?parseFloat(n):1}}).sort((e,t)=>t.q-e.q);for(let{lang:e}of n){if(t.includes(e))return e;let n=e.split(`-`)[0];if(t.includes(n))return n}return null}function o(e){try{let n=(0,t.useRoute)().query.locale;n&&e.locales.includes(n)&&e.setLocale(n)}catch{}}var s={path:n,cookie:r,header:i,query:o};async function c(e,t,n,r){let i=null,a=!1,o={path:e,locales:t.locales,defaultLocale:t.defaultLocale,strategy:t.strategy,...t.detectBrowserLanguage?{detectBrowserLanguage:t.detectBrowserLanguage}:{},detectedLocale:null,setLocale(e){t.locales.includes(e)&&(i=e,o.detectedLocale=e,a=!0)},isServer:{}.server??!1};for(let e of t.detectOrder){if(a)break;let t=s[e]??n?.get(e);t&&await t(o)}return r&&!a&&await r(o),i??t.detectBrowserLanguage?.fallbackLocale??t.defaultLocale}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return c}});
|
|
2
|
-
//# sourceMappingURL=detectors-CFJvuwzi.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detectors-CFJvuwzi.cjs","names":[],"sources":["../src/runtime/detectors/path.ts","../src/runtime/detectors/cookie.ts","../src/runtime/detectors/header.ts","../src/runtime/detectors/query.ts","../src/runtime/detectors/index.ts"],"sourcesContent":["import type { LocaleDetectContext } from '../../types'\nimport { extractLocaleFromPath } from '../path-utils'\n\n/** Detect locale from URL path prefix (e.g. /ja/about → 'ja') */\nexport default function detectPath(ctx: LocaleDetectContext): void {\n if (ctx.strategy === 'no_prefix') return\n const { locale } = extractLocaleFromPath(ctx.path, ctx.locales)\n if (locale) {\n ctx.setLocale(locale)\n }\n}\n","import { useCookie } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\n\n/** Detect locale from cookie value */\nexport default function detectCookie(ctx: LocaleDetectContext): void {\n if (!ctx.detectBrowserLanguage?.useCookie) return\n const cookieKey = ctx.detectBrowserLanguage.cookieKey ?? 'fluenti_locale'\n try {\n const cookie = useCookie(cookieKey)\n if (cookie.value && ctx.locales.includes(cookie.value)) {\n ctx.setLocale(cookie.value)\n }\n } catch {\n // useCookie may fail outside Nuxt context\n }\n}\n","import { useRequestHeaders } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\n\n/** Detect locale from Accept-Language header (SSR only) */\nexport default function detectHeader(ctx: LocaleDetectContext): void {\n if (!ctx.isServer) return\n try {\n const headers = useRequestHeaders(['accept-language'])\n const acceptLang = headers['accept-language']\n if (acceptLang) {\n const matched = negotiateLocale(acceptLang, ctx.locales)\n if (matched) {\n ctx.setLocale(matched)\n }\n }\n } catch {\n // May fail if not in a request context\n }\n}\n\nfunction negotiateLocale(acceptLanguage: string, locales: string[]): string | null {\n const preferred = acceptLanguage\n .split(',')\n .map((part) => {\n const [lang, q] = part.trim().split(';q=')\n return { lang: lang!.trim().toLowerCase(), q: q ? parseFloat(q) : 1 }\n })\n .sort((a, b) => b.q - a.q)\n\n for (const { lang } of preferred) {\n if (locales.includes(lang)) return lang\n const prefix = lang.split('-')[0]!\n if (locales.includes(prefix)) return prefix\n }\n\n return null\n}\n","import { useRoute } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\n\n/** Detect locale from query parameter (e.g. ?locale=ja) */\nexport default function detectQuery(ctx: LocaleDetectContext): void {\n try {\n const route = useRoute()\n const queryLocale = route.query['locale'] as string | undefined\n if (queryLocale && ctx.locales.includes(queryLocale)) {\n ctx.setLocale(queryLocale)\n }\n } catch {\n // May fail outside Nuxt context\n }\n}\n","import type { LocaleDetectContext, LocaleDetectorFn, FluentNuxtRuntimeConfig } from '../../types'\nimport detectPath from './path'\nimport detectCookie from './cookie'\nimport detectHeader from './header'\nimport detectQuery from './query'\n\n/** Map of built-in detector names to their implementations */\nconst builtinDetectors: Record<string, LocaleDetectorFn> = {\n path: detectPath,\n cookie: detectCookie,\n header: detectHeader,\n query: detectQuery,\n}\n\n/**\n * Run the detection chain: iterate through detectOrder, then fire the hook.\n *\n * Returns the detected locale or the defaultLocale as fallback.\n */\nexport async function runDetectors(\n path: string,\n config: FluentNuxtRuntimeConfig,\n customDetectors?: Map<string, LocaleDetectorFn>,\n hookFn?: (ctx: LocaleDetectContext) => void | Promise<void>,\n): Promise<string> {\n let resolved: string | null = null\n let stopped = false\n\n const ctx: LocaleDetectContext = {\n path,\n locales: config.locales,\n defaultLocale: config.defaultLocale,\n strategy: config.strategy,\n ...(config.detectBrowserLanguage ? { detectBrowserLanguage: config.detectBrowserLanguage } : {}),\n detectedLocale: null,\n setLocale(locale: string) {\n if (config.locales.includes(locale)) {\n resolved = locale\n ctx.detectedLocale = locale\n stopped = true\n }\n },\n isServer: import.meta.server ?? false,\n }\n\n // 1. Run detectors in order\n for (const name of config.detectOrder) {\n if (stopped) break\n\n const detector = builtinDetectors[name] ?? customDetectors?.get(name)\n if (detector) {\n await detector(ctx)\n }\n }\n\n // 2. Fire the hook — allows overriding or supplementing the detection chain\n if (hookFn && !stopped) {\n await hookFn(ctx)\n }\n\n // 3. Fallback\n return resolved ?? config.detectBrowserLanguage?.fallbackLocale ?? config.defaultLocale\n}\n\nexport { builtinDetectors }\nexport type { LocaleDetectContext, LocaleDetectorFn }\n"],"mappings":"uEAIA,SAAwB,EAAW,EAAgC,CACjE,GAAI,EAAI,WAAa,YAAa,OAClC,GAAM,CAAE,UAAW,EAAA,EAAsB,EAAI,KAAM,EAAI,QAAQ,CAC3D,GACF,EAAI,UAAU,EAAO,CCJzB,SAAwB,EAAa,EAAgC,CACnE,GAAI,CAAC,EAAI,uBAAuB,UAAW,OAC3C,IAAM,EAAY,EAAI,sBAAsB,WAAa,iBACzD,GAAI,CACF,IAAM,GAAA,EAAA,EAAA,WAAmB,EAAU,CAC/B,EAAO,OAAS,EAAI,QAAQ,SAAS,EAAO,MAAM,EACpD,EAAI,UAAU,EAAO,MAAM,MAEvB,GCRV,SAAwB,EAAa,EAAgC,CAC9D,KAAI,SACT,GAAI,CAEF,IAAM,GAAA,EAAA,EAAA,mBAD4B,CAAC,kBAAkB,CAAC,CAC3B,mBAC3B,GAAI,EAAY,CACd,IAAM,EAAU,EAAgB,EAAY,EAAI,QAAQ,CACpD,GACF,EAAI,UAAU,EAAQ,OAGpB,GAKV,SAAS,EAAgB,EAAwB,EAAkC,CACjF,IAAM,EAAY,EACf,MAAM,IAAI,CACV,IAAK,GAAS,CACb,GAAM,CAAC,EAAM,GAAK,EAAK,MAAM,CAAC,MAAM,MAAM,CAC1C,MAAO,CAAE,KAAM,EAAM,MAAM,CAAC,aAAa,CAAE,EAAG,EAAI,WAAW,EAAE,CAAG,EAAG,EACrE,CACD,MAAM,EAAG,IAAM,EAAE,EAAI,EAAE,EAAE,CAE5B,IAAK,GAAM,CAAE,UAAU,EAAW,CAChC,GAAI,EAAQ,SAAS,EAAK,CAAE,OAAO,EACnC,IAAM,EAAS,EAAK,MAAM,IAAI,CAAC,GAC/B,GAAI,EAAQ,SAAS,EAAO,CAAE,OAAO,EAGvC,OAAO,KC/BT,SAAwB,EAAY,EAAgC,CAClE,GAAI,CAEF,IAAM,GAAA,EAAA,EAAA,WADkB,CACE,MAAM,OAC5B,GAAe,EAAI,QAAQ,SAAS,EAAY,EAClD,EAAI,UAAU,EAAY,MAEtB,GCJV,IAAM,EAAqD,CACzD,KAAM,EACN,OAAQ,EACR,OAAQ,EACR,MAAO,EACR,CAOD,eAAsB,EACpB,EACA,EACA,EACA,EACiB,CACjB,IAAI,EAA0B,KAC1B,EAAU,GAER,EAA2B,CAC/B,OACA,QAAS,EAAO,QAChB,cAAe,EAAO,cACtB,SAAU,EAAO,SACjB,GAAI,EAAO,sBAAwB,CAAE,sBAAuB,EAAO,sBAAuB,CAAG,EAAE,CAC/F,eAAgB,KAChB,UAAU,EAAgB,CACpB,EAAO,QAAQ,SAAS,EAAO,GACjC,EAAW,EACX,EAAI,eAAiB,EACrB,EAAU,KAGd,SAAA,EAAA,CAAsB,QAAU,GACjC,CAGD,IAAK,IAAM,KAAQ,EAAO,YAAa,CACrC,GAAI,EAAS,MAEb,IAAM,EAAW,EAAiB,IAAS,GAAiB,IAAI,EAAK,CACjE,GACF,MAAM,EAAS,EAAI,CAUvB,OALI,GAAU,CAAC,GACb,MAAM,EAAO,EAAI,CAIZ,GAAY,EAAO,uBAAuB,gBAAkB,EAAO"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./path-utils-BcvXLCGi.js";
|
|
2
|
-
import { useCookie as t, useRequestHeaders as n, useRoute as r } from "#imports";
|
|
3
|
-
//#region src/runtime/detectors/path.ts
|
|
4
|
-
function i(t) {
|
|
5
|
-
if (t.strategy === "no_prefix") return;
|
|
6
|
-
let { locale: n } = e(t.path, t.locales);
|
|
7
|
-
n && t.setLocale(n);
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/runtime/detectors/cookie.ts
|
|
11
|
-
function a(e) {
|
|
12
|
-
if (!e.detectBrowserLanguage?.useCookie) return;
|
|
13
|
-
let n = e.detectBrowserLanguage.cookieKey ?? "fluenti_locale";
|
|
14
|
-
try {
|
|
15
|
-
let r = t(n);
|
|
16
|
-
r.value && e.locales.includes(r.value) && e.setLocale(r.value);
|
|
17
|
-
} catch {}
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/runtime/detectors/header.ts
|
|
21
|
-
function o(e) {
|
|
22
|
-
if (e.isServer) try {
|
|
23
|
-
let t = n(["accept-language"])["accept-language"];
|
|
24
|
-
if (t) {
|
|
25
|
-
let n = s(t, e.locales);
|
|
26
|
-
n && e.setLocale(n);
|
|
27
|
-
}
|
|
28
|
-
} catch {}
|
|
29
|
-
}
|
|
30
|
-
function s(e, t) {
|
|
31
|
-
let n = e.split(",").map((e) => {
|
|
32
|
-
let [t, n] = e.trim().split(";q=");
|
|
33
|
-
return {
|
|
34
|
-
lang: t.trim().toLowerCase(),
|
|
35
|
-
q: n ? parseFloat(n) : 1
|
|
36
|
-
};
|
|
37
|
-
}).sort((e, t) => t.q - e.q);
|
|
38
|
-
for (let { lang: e } of n) {
|
|
39
|
-
if (t.includes(e)) return e;
|
|
40
|
-
let n = e.split("-")[0];
|
|
41
|
-
if (t.includes(n)) return n;
|
|
42
|
-
}
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/runtime/detectors/query.ts
|
|
47
|
-
function c(e) {
|
|
48
|
-
try {
|
|
49
|
-
let t = r().query.locale;
|
|
50
|
-
t && e.locales.includes(t) && e.setLocale(t);
|
|
51
|
-
} catch {}
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region src/runtime/detectors/index.ts
|
|
55
|
-
var l = {
|
|
56
|
-
path: i,
|
|
57
|
-
cookie: a,
|
|
58
|
-
header: o,
|
|
59
|
-
query: c
|
|
60
|
-
};
|
|
61
|
-
async function u(e, t, n, r) {
|
|
62
|
-
let i = null, a = !1, o = {
|
|
63
|
-
path: e,
|
|
64
|
-
locales: t.locales,
|
|
65
|
-
defaultLocale: t.defaultLocale,
|
|
66
|
-
strategy: t.strategy,
|
|
67
|
-
...t.detectBrowserLanguage ? { detectBrowserLanguage: t.detectBrowserLanguage } : {},
|
|
68
|
-
detectedLocale: null,
|
|
69
|
-
setLocale(e) {
|
|
70
|
-
t.locales.includes(e) && (i = e, o.detectedLocale = e, a = !0);
|
|
71
|
-
},
|
|
72
|
-
isServer: import.meta.server ?? !1
|
|
73
|
-
};
|
|
74
|
-
for (let e of t.detectOrder) {
|
|
75
|
-
if (a) break;
|
|
76
|
-
let t = l[e] ?? n?.get(e);
|
|
77
|
-
t && await t(o);
|
|
78
|
-
}
|
|
79
|
-
return r && !a && await r(o), i ?? t.detectBrowserLanguage?.fallbackLocale ?? t.defaultLocale;
|
|
80
|
-
}
|
|
81
|
-
//#endregion
|
|
82
|
-
export { u as t };
|
|
83
|
-
|
|
84
|
-
//# sourceMappingURL=detectors-DhkfHBHr.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detectors-DhkfHBHr.js","names":[],"sources":["../src/runtime/detectors/path.ts","../src/runtime/detectors/cookie.ts","../src/runtime/detectors/header.ts","../src/runtime/detectors/query.ts","../src/runtime/detectors/index.ts"],"sourcesContent":["import type { LocaleDetectContext } from '../../types'\nimport { extractLocaleFromPath } from '../path-utils'\n\n/** Detect locale from URL path prefix (e.g. /ja/about → 'ja') */\nexport default function detectPath(ctx: LocaleDetectContext): void {\n if (ctx.strategy === 'no_prefix') return\n const { locale } = extractLocaleFromPath(ctx.path, ctx.locales)\n if (locale) {\n ctx.setLocale(locale)\n }\n}\n","import { useCookie } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\n\n/** Detect locale from cookie value */\nexport default function detectCookie(ctx: LocaleDetectContext): void {\n if (!ctx.detectBrowserLanguage?.useCookie) return\n const cookieKey = ctx.detectBrowserLanguage.cookieKey ?? 'fluenti_locale'\n try {\n const cookie = useCookie(cookieKey)\n if (cookie.value && ctx.locales.includes(cookie.value)) {\n ctx.setLocale(cookie.value)\n }\n } catch {\n // useCookie may fail outside Nuxt context\n }\n}\n","import { useRequestHeaders } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\n\n/** Detect locale from Accept-Language header (SSR only) */\nexport default function detectHeader(ctx: LocaleDetectContext): void {\n if (!ctx.isServer) return\n try {\n const headers = useRequestHeaders(['accept-language'])\n const acceptLang = headers['accept-language']\n if (acceptLang) {\n const matched = negotiateLocale(acceptLang, ctx.locales)\n if (matched) {\n ctx.setLocale(matched)\n }\n }\n } catch {\n // May fail if not in a request context\n }\n}\n\nfunction negotiateLocale(acceptLanguage: string, locales: string[]): string | null {\n const preferred = acceptLanguage\n .split(',')\n .map((part) => {\n const [lang, q] = part.trim().split(';q=')\n return { lang: lang!.trim().toLowerCase(), q: q ? parseFloat(q) : 1 }\n })\n .sort((a, b) => b.q - a.q)\n\n for (const { lang } of preferred) {\n if (locales.includes(lang)) return lang\n const prefix = lang.split('-')[0]!\n if (locales.includes(prefix)) return prefix\n }\n\n return null\n}\n","import { useRoute } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\n\n/** Detect locale from query parameter (e.g. ?locale=ja) */\nexport default function detectQuery(ctx: LocaleDetectContext): void {\n try {\n const route = useRoute()\n const queryLocale = route.query['locale'] as string | undefined\n if (queryLocale && ctx.locales.includes(queryLocale)) {\n ctx.setLocale(queryLocale)\n }\n } catch {\n // May fail outside Nuxt context\n }\n}\n","import type { LocaleDetectContext, LocaleDetectorFn, FluentNuxtRuntimeConfig } from '../../types'\nimport detectPath from './path'\nimport detectCookie from './cookie'\nimport detectHeader from './header'\nimport detectQuery from './query'\n\n/** Map of built-in detector names to their implementations */\nconst builtinDetectors: Record<string, LocaleDetectorFn> = {\n path: detectPath,\n cookie: detectCookie,\n header: detectHeader,\n query: detectQuery,\n}\n\n/**\n * Run the detection chain: iterate through detectOrder, then fire the hook.\n *\n * Returns the detected locale or the defaultLocale as fallback.\n */\nexport async function runDetectors(\n path: string,\n config: FluentNuxtRuntimeConfig,\n customDetectors?: Map<string, LocaleDetectorFn>,\n hookFn?: (ctx: LocaleDetectContext) => void | Promise<void>,\n): Promise<string> {\n let resolved: string | null = null\n let stopped = false\n\n const ctx: LocaleDetectContext = {\n path,\n locales: config.locales,\n defaultLocale: config.defaultLocale,\n strategy: config.strategy,\n ...(config.detectBrowserLanguage ? { detectBrowserLanguage: config.detectBrowserLanguage } : {}),\n detectedLocale: null,\n setLocale(locale: string) {\n if (config.locales.includes(locale)) {\n resolved = locale\n ctx.detectedLocale = locale\n stopped = true\n }\n },\n isServer: import.meta.server ?? false,\n }\n\n // 1. Run detectors in order\n for (const name of config.detectOrder) {\n if (stopped) break\n\n const detector = builtinDetectors[name] ?? customDetectors?.get(name)\n if (detector) {\n await detector(ctx)\n }\n }\n\n // 2. Fire the hook — allows overriding or supplementing the detection chain\n if (hookFn && !stopped) {\n await hookFn(ctx)\n }\n\n // 3. Fallback\n return resolved ?? config.detectBrowserLanguage?.fallbackLocale ?? config.defaultLocale\n}\n\nexport { builtinDetectors }\nexport type { LocaleDetectContext, LocaleDetectorFn }\n"],"mappings":";;;AAIA,SAAwB,EAAW,GAAgC;AACjE,KAAI,EAAI,aAAa,YAAa;CAClC,IAAM,EAAE,cAAW,EAAsB,EAAI,MAAM,EAAI,QAAQ;AAC/D,CAAI,KACF,EAAI,UAAU,EAAO;;;;ACJzB,SAAwB,EAAa,GAAgC;AACnE,KAAI,CAAC,EAAI,uBAAuB,UAAW;CAC3C,IAAM,IAAY,EAAI,sBAAsB,aAAa;AACzD,KAAI;EACF,IAAM,IAAS,EAAU,EAAU;AACnC,EAAI,EAAO,SAAS,EAAI,QAAQ,SAAS,EAAO,MAAM,IACpD,EAAI,UAAU,EAAO,MAAM;SAEvB;;;;ACRV,SAAwB,EAAa,GAAgC;AAC9D,OAAI,SACT,KAAI;EAEF,IAAM,IADU,EAAkB,CAAC,kBAAkB,CAAC,CAC3B;AAC3B,MAAI,GAAY;GACd,IAAM,IAAU,EAAgB,GAAY,EAAI,QAAQ;AACxD,GAAI,KACF,EAAI,UAAU,EAAQ;;SAGpB;;AAKV,SAAS,EAAgB,GAAwB,GAAkC;CACjF,IAAM,IAAY,EACf,MAAM,IAAI,CACV,KAAK,MAAS;EACb,IAAM,CAAC,GAAM,KAAK,EAAK,MAAM,CAAC,MAAM,MAAM;AAC1C,SAAO;GAAE,MAAM,EAAM,MAAM,CAAC,aAAa;GAAE,GAAG,IAAI,WAAW,EAAE,GAAG;GAAG;GACrE,CACD,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,EAAE;AAE5B,MAAK,IAAM,EAAE,aAAU,GAAW;AAChC,MAAI,EAAQ,SAAS,EAAK,CAAE,QAAO;EACnC,IAAM,IAAS,EAAK,MAAM,IAAI,CAAC;AAC/B,MAAI,EAAQ,SAAS,EAAO,CAAE,QAAO;;AAGvC,QAAO;;;;AC/BT,SAAwB,EAAY,GAAgC;AAClE,KAAI;EAEF,IAAM,IADQ,GAAU,CACE,MAAM;AAChC,EAAI,KAAe,EAAI,QAAQ,SAAS,EAAY,IAClD,EAAI,UAAU,EAAY;SAEtB;;;;ACJV,IAAM,IAAqD;CACzD,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,OAAO;CACR;AAOD,eAAsB,EACpB,GACA,GACA,GACA,GACiB;CACjB,IAAI,IAA0B,MAC1B,IAAU,IAER,IAA2B;EAC/B;EACA,SAAS,EAAO;EAChB,eAAe,EAAO;EACtB,UAAU,EAAO;EACjB,GAAI,EAAO,wBAAwB,EAAE,uBAAuB,EAAO,uBAAuB,GAAG,EAAE;EAC/F,gBAAgB;EAChB,UAAU,GAAgB;AACxB,GAAI,EAAO,QAAQ,SAAS,EAAO,KACjC,IAAW,GACX,EAAI,iBAAiB,GACrB,IAAU;;EAGd,UAAU,OAAO,KAAK,UAAU;EACjC;AAGD,MAAK,IAAM,KAAQ,EAAO,aAAa;AACrC,MAAI,EAAS;EAEb,IAAM,IAAW,EAAiB,MAAS,GAAiB,IAAI,EAAK;AACrE,EAAI,KACF,MAAM,EAAS,EAAI;;AAUvB,QALI,KAAU,CAAC,KACb,MAAM,EAAO,EAAI,EAIZ,KAAY,EAAO,uBAAuB,kBAAkB,EAAO"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require(`./path-utils-BQIsp_or.cjs`);function t(t,n,r,i){let a={htmlAttrs:{lang:t},link:[],meta:[]};if(i?.addSeoAttributes){let o=i.baseUrl??``;for(let t of r.locales){let i=e.r(n,t,r.locales,r.defaultLocale,r.strategy);a.link.push({rel:`alternate`,hreflang:t,href:`${o}${i}`})}let s=e.r(n,r.defaultLocale,r.locales,r.defaultLocale,r.strategy);a.link.push({rel:`alternate`,hreflang:`x-default`,href:`${o}${s}`}),a.meta.push({property:`og:locale`,content:t});for(let e of r.locales)e!==t&&a.meta.push({property:`og:locale:alternate`,content:e})}return a}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
2
|
-
//# sourceMappingURL=locale-head-BfsESdd7.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"locale-head-BfsESdd7.cjs","names":[],"sources":["../src/runtime/locale-head.ts"],"sourcesContent":["import { switchLocalePath } from './path-utils'\nimport type { FluentNuxtRuntimeConfig } from '../types'\n\n/** Head metadata for locale SEO */\nexport interface LocaleHeadMeta {\n htmlAttrs: { lang: string }\n link: Array<{ rel: string; hreflang: string; href: string }>\n meta: Array<{ property: string; content: string }>\n}\n\nexport interface LocaleHeadOptions {\n /** Add hreflang and og:locale SEO attributes */\n addSeoAttributes?: boolean\n /** Base URL for absolute hreflang links (e.g. 'https://example.com') */\n baseUrl?: string\n}\n\n/**\n * Pure function that builds locale-aware HTML head metadata.\n *\n * This is the framework-agnostic core logic. For the Nuxt composable,\n * use `useLocaleHead()` from `composables.ts` instead.\n */\nexport function buildLocaleHead(\n locale: string,\n currentPath: string,\n config: FluentNuxtRuntimeConfig,\n options?: LocaleHeadOptions,\n): LocaleHeadMeta {\n const head: LocaleHeadMeta = {\n htmlAttrs: { lang: locale },\n link: [],\n meta: [],\n }\n\n if (options?.addSeoAttributes) {\n const baseUrl = options.baseUrl ?? ''\n\n // hreflang alternate links for each locale\n for (const loc of config.locales) {\n const path = switchLocalePath(\n currentPath,\n loc,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n head.link.push({\n rel: 'alternate',\n hreflang: loc,\n href: `${baseUrl}${path}`,\n })\n }\n\n // x-default hreflang\n const defaultPath = switchLocalePath(\n currentPath,\n config.defaultLocale,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n head.link.push({\n rel: 'alternate',\n hreflang: 'x-default',\n href: `${baseUrl}${defaultPath}`,\n })\n\n // og:locale\n head.meta.push({ property: 'og:locale', content: locale })\n\n // og:locale:alternate for other locales\n for (const loc of config.locales) {\n if (loc !== locale) {\n head.meta.push({ property: 'og:locale:alternate', content: loc })\n }\n }\n }\n\n return head\n}\n"],"mappings":"6CAuBA,SAAgB,EACd,EACA,EACA,EACA,EACgB,CAChB,IAAM,EAAuB,CAC3B,UAAW,CAAE,KAAM,EAAQ,CAC3B,KAAM,EAAE,CACR,KAAM,EAAE,CACT,CAED,GAAI,GAAS,iBAAkB,CAC7B,IAAM,EAAU,EAAQ,SAAW,GAGnC,IAAK,IAAM,KAAO,EAAO,QAAS,CAChC,IAAM,EAAO,EAAA,EACX,EACA,EACA,EAAO,QACP,EAAO,cACP,EAAO,SACR,CACD,EAAK,KAAK,KAAK,CACb,IAAK,YACL,SAAU,EACV,KAAM,GAAG,IAAU,IACpB,CAAC,CAIJ,IAAM,EAAc,EAAA,EAClB,EACA,EAAO,cACP,EAAO,QACP,EAAO,cACP,EAAO,SACR,CACD,EAAK,KAAK,KAAK,CACb,IAAK,YACL,SAAU,YACV,KAAM,GAAG,IAAU,IACpB,CAAC,CAGF,EAAK,KAAK,KAAK,CAAE,SAAU,YAAa,QAAS,EAAQ,CAAC,CAG1D,IAAK,IAAM,KAAO,EAAO,QACnB,IAAQ,GACV,EAAK,KAAK,KAAK,CAAE,SAAU,sBAAuB,QAAS,EAAK,CAAC,CAKvE,OAAO"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { r as e } from "./path-utils-BcvXLCGi.js";
|
|
2
|
-
//#region src/runtime/locale-head.ts
|
|
3
|
-
function t(t, n, r, i) {
|
|
4
|
-
let a = {
|
|
5
|
-
htmlAttrs: { lang: t },
|
|
6
|
-
link: [],
|
|
7
|
-
meta: []
|
|
8
|
-
};
|
|
9
|
-
if (i?.addSeoAttributes) {
|
|
10
|
-
let o = i.baseUrl ?? "";
|
|
11
|
-
for (let t of r.locales) {
|
|
12
|
-
let i = e(n, t, r.locales, r.defaultLocale, r.strategy);
|
|
13
|
-
a.link.push({
|
|
14
|
-
rel: "alternate",
|
|
15
|
-
hreflang: t,
|
|
16
|
-
href: `${o}${i}`
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
let s = e(n, r.defaultLocale, r.locales, r.defaultLocale, r.strategy);
|
|
20
|
-
a.link.push({
|
|
21
|
-
rel: "alternate",
|
|
22
|
-
hreflang: "x-default",
|
|
23
|
-
href: `${o}${s}`
|
|
24
|
-
}), a.meta.push({
|
|
25
|
-
property: "og:locale",
|
|
26
|
-
content: t
|
|
27
|
-
});
|
|
28
|
-
for (let e of r.locales) e !== t && a.meta.push({
|
|
29
|
-
property: "og:locale:alternate",
|
|
30
|
-
content: e
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return a;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { t };
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=locale-head-CqUlvy3O.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"locale-head-CqUlvy3O.js","names":[],"sources":["../src/runtime/locale-head.ts"],"sourcesContent":["import { switchLocalePath } from './path-utils'\nimport type { FluentNuxtRuntimeConfig } from '../types'\n\n/** Head metadata for locale SEO */\nexport interface LocaleHeadMeta {\n htmlAttrs: { lang: string }\n link: Array<{ rel: string; hreflang: string; href: string }>\n meta: Array<{ property: string; content: string }>\n}\n\nexport interface LocaleHeadOptions {\n /** Add hreflang and og:locale SEO attributes */\n addSeoAttributes?: boolean\n /** Base URL for absolute hreflang links (e.g. 'https://example.com') */\n baseUrl?: string\n}\n\n/**\n * Pure function that builds locale-aware HTML head metadata.\n *\n * This is the framework-agnostic core logic. For the Nuxt composable,\n * use `useLocaleHead()` from `composables.ts` instead.\n */\nexport function buildLocaleHead(\n locale: string,\n currentPath: string,\n config: FluentNuxtRuntimeConfig,\n options?: LocaleHeadOptions,\n): LocaleHeadMeta {\n const head: LocaleHeadMeta = {\n htmlAttrs: { lang: locale },\n link: [],\n meta: [],\n }\n\n if (options?.addSeoAttributes) {\n const baseUrl = options.baseUrl ?? ''\n\n // hreflang alternate links for each locale\n for (const loc of config.locales) {\n const path = switchLocalePath(\n currentPath,\n loc,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n head.link.push({\n rel: 'alternate',\n hreflang: loc,\n href: `${baseUrl}${path}`,\n })\n }\n\n // x-default hreflang\n const defaultPath = switchLocalePath(\n currentPath,\n config.defaultLocale,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n head.link.push({\n rel: 'alternate',\n hreflang: 'x-default',\n href: `${baseUrl}${defaultPath}`,\n })\n\n // og:locale\n head.meta.push({ property: 'og:locale', content: locale })\n\n // og:locale:alternate for other locales\n for (const loc of config.locales) {\n if (loc !== locale) {\n head.meta.push({ property: 'og:locale:alternate', content: loc })\n }\n }\n }\n\n return head\n}\n"],"mappings":";;AAuBA,SAAgB,EACd,GACA,GACA,GACA,GACgB;CAChB,IAAM,IAAuB;EAC3B,WAAW,EAAE,MAAM,GAAQ;EAC3B,MAAM,EAAE;EACR,MAAM,EAAE;EACT;AAED,KAAI,GAAS,kBAAkB;EAC7B,IAAM,IAAU,EAAQ,WAAW;AAGnC,OAAK,IAAM,KAAO,EAAO,SAAS;GAChC,IAAM,IAAO,EACX,GACA,GACA,EAAO,SACP,EAAO,eACP,EAAO,SACR;AACD,KAAK,KAAK,KAAK;IACb,KAAK;IACL,UAAU;IACV,MAAM,GAAG,IAAU;IACpB,CAAC;;EAIJ,IAAM,IAAc,EAClB,GACA,EAAO,eACP,EAAO,SACP,EAAO,eACP,EAAO,SACR;AAQD,EAPA,EAAK,KAAK,KAAK;GACb,KAAK;GACL,UAAU;GACV,MAAM,GAAG,IAAU;GACpB,CAAC,EAGF,EAAK,KAAK,KAAK;GAAE,UAAU;GAAa,SAAS;GAAQ,CAAC;AAG1D,OAAK,IAAM,KAAO,EAAO,QACvB,CAAI,MAAQ,KACV,EAAK,KAAK,KAAK;GAAE,UAAU;GAAuB,SAAS;GAAK,CAAC;;AAKvE,QAAO"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region src/runtime/page-extend.ts
|
|
2
|
-
function e(e, n) {
|
|
3
|
-
let { locales: r, defaultLocale: i, strategy: a } = n;
|
|
4
|
-
if (a === "no_prefix") return;
|
|
5
|
-
let o = [...e];
|
|
6
|
-
for (let n of r) if (!(a === "prefix_except_default" && n === i)) for (let r of o) {
|
|
7
|
-
let i = t(r, n);
|
|
8
|
-
e.push(i);
|
|
9
|
-
}
|
|
10
|
-
a === "prefix" && e.splice(0, o.length);
|
|
11
|
-
}
|
|
12
|
-
function t(e, t) {
|
|
13
|
-
let n = {
|
|
14
|
-
...e,
|
|
15
|
-
path: `/${t}${e.path === "/" ? "" : e.path}`
|
|
16
|
-
};
|
|
17
|
-
return e.name && (n.name = `${e.name}___${t}`), e.children && (n.children = e.children.map((e) => {
|
|
18
|
-
let n = { ...e };
|
|
19
|
-
return e.name && (n.name = `${e.name}___${t}`), n;
|
|
20
|
-
})), n;
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { e as t };
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=page-extend-DJ7wpuVj.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"page-extend-DJ7wpuVj.js","names":[],"sources":["../src/runtime/page-extend.ts"],"sourcesContent":["import type { Strategy } from '../types'\n\n/** Page route definition used for route extension */\nexport interface PageRoute {\n path: string\n name?: string\n children?: PageRoute[]\n}\n\n/**\n * Extend page routes with locale-prefixed variants.\n * Mutates the pages array in place (Nuxt convention).\n *\n * This is a build-time utility used in the module's `pages:extend` hook.\n */\nexport function extendPages(\n pages: PageRoute[],\n options: { locales: string[]; defaultLocale: string; strategy: Strategy },\n): void {\n const { locales, defaultLocale, strategy } = options\n if (strategy === 'no_prefix') return\n\n const originalPages = [...pages]\n\n for (const locale of locales) {\n // For prefix_except_default, skip creating prefixed routes for the default locale\n if (strategy === 'prefix_except_default' && locale === defaultLocale) continue\n\n for (const page of originalPages) {\n const prefixedPage = prefixPage(page, locale)\n pages.push(prefixedPage)\n }\n }\n\n // For prefix strategy, remove the original unprefixed routes\n // (every locale including default must have a prefix)\n if (strategy === 'prefix') {\n // Remove all original pages (they'll only exist as prefixed versions)\n pages.splice(0, originalPages.length)\n }\n}\n\nfunction prefixPage(page: PageRoute, locale: string): PageRoute {\n const prefixed: PageRoute = {\n ...page,\n path: `/${locale}${page.path === '/' ? '' : page.path}`,\n }\n if (page.name) {\n prefixed.name = `${page.name}___${locale}`\n }\n\n if (page.children) {\n prefixed.children = page.children.map((child) => {\n const prefixedChild: PageRoute = { ...child }\n if (child.name) {\n prefixedChild.name = `${child.name}___${locale}`\n }\n return prefixedChild\n })\n }\n\n return prefixed\n}\n"],"mappings":";AAeA,SAAgB,EACd,GACA,GACM;CACN,IAAM,EAAE,YAAS,kBAAe,gBAAa;AAC7C,KAAI,MAAa,YAAa;CAE9B,IAAM,IAAgB,CAAC,GAAG,EAAM;AAEhC,MAAK,IAAM,KAAU,EAEf,aAAa,2BAA2B,MAAW,GAEvD,MAAK,IAAM,KAAQ,GAAe;EAChC,IAAM,IAAe,EAAW,GAAM,EAAO;AAC7C,IAAM,KAAK,EAAa;;AAM5B,CAAI,MAAa,YAEf,EAAM,OAAO,GAAG,EAAc,OAAO;;AAIzC,SAAS,EAAW,GAAiB,GAA2B;CAC9D,IAAM,IAAsB;EAC1B,GAAG;EACH,MAAM,IAAI,IAAS,EAAK,SAAS,MAAM,KAAK,EAAK;EAClD;AAeD,QAdI,EAAK,SACP,EAAS,OAAO,GAAG,EAAK,KAAK,KAAK,MAGhC,EAAK,aACP,EAAS,WAAW,EAAK,SAAS,KAAK,MAAU;EAC/C,IAAM,IAA2B,EAAE,GAAG,GAAO;AAI7C,SAHI,EAAM,SACR,EAAc,OAAO,GAAG,EAAM,KAAK,KAAK,MAEnC;GACP,GAGG"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function e(e,n){let{locales:r,defaultLocale:i,strategy:a}=n;if(a===`no_prefix`)return;let o=[...e];for(let n of r)if(!(a===`prefix_except_default`&&n===i))for(let r of o){let i=t(r,n);e.push(i)}a===`prefix`&&e.splice(0,o.length)}function t(e,t){let n={...e,path:`/${t}${e.path===`/`?``:e.path}`};return e.name&&(n.name=`${e.name}___${t}`),e.children&&(n.children=e.children.map(e=>{let n={...e};return e.name&&(n.name=`${e.name}___${t}`),n})),n}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
2
|
-
//# sourceMappingURL=page-extend-OvV-ZhFB.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"page-extend-OvV-ZhFB.cjs","names":[],"sources":["../src/runtime/page-extend.ts"],"sourcesContent":["import type { Strategy } from '../types'\n\n/** Page route definition used for route extension */\nexport interface PageRoute {\n path: string\n name?: string\n children?: PageRoute[]\n}\n\n/**\n * Extend page routes with locale-prefixed variants.\n * Mutates the pages array in place (Nuxt convention).\n *\n * This is a build-time utility used in the module's `pages:extend` hook.\n */\nexport function extendPages(\n pages: PageRoute[],\n options: { locales: string[]; defaultLocale: string; strategy: Strategy },\n): void {\n const { locales, defaultLocale, strategy } = options\n if (strategy === 'no_prefix') return\n\n const originalPages = [...pages]\n\n for (const locale of locales) {\n // For prefix_except_default, skip creating prefixed routes for the default locale\n if (strategy === 'prefix_except_default' && locale === defaultLocale) continue\n\n for (const page of originalPages) {\n const prefixedPage = prefixPage(page, locale)\n pages.push(prefixedPage)\n }\n }\n\n // For prefix strategy, remove the original unprefixed routes\n // (every locale including default must have a prefix)\n if (strategy === 'prefix') {\n // Remove all original pages (they'll only exist as prefixed versions)\n pages.splice(0, originalPages.length)\n }\n}\n\nfunction prefixPage(page: PageRoute, locale: string): PageRoute {\n const prefixed: PageRoute = {\n ...page,\n path: `/${locale}${page.path === '/' ? '' : page.path}`,\n }\n if (page.name) {\n prefixed.name = `${page.name}___${locale}`\n }\n\n if (page.children) {\n prefixed.children = page.children.map((child) => {\n const prefixedChild: PageRoute = { ...child }\n if (child.name) {\n prefixedChild.name = `${child.name}___${locale}`\n }\n return prefixedChild\n })\n }\n\n return prefixed\n}\n"],"mappings":"AAeA,SAAgB,EACd,EACA,EACM,CACN,GAAM,CAAE,UAAS,gBAAe,YAAa,EAC7C,GAAI,IAAa,YAAa,OAE9B,IAAM,EAAgB,CAAC,GAAG,EAAM,CAEhC,IAAK,IAAM,KAAU,EAEf,SAAa,yBAA2B,IAAW,GAEvD,IAAK,IAAM,KAAQ,EAAe,CAChC,IAAM,EAAe,EAAW,EAAM,EAAO,CAC7C,EAAM,KAAK,EAAa,CAMxB,IAAa,UAEf,EAAM,OAAO,EAAG,EAAc,OAAO,CAIzC,SAAS,EAAW,EAAiB,EAA2B,CAC9D,IAAM,EAAsB,CAC1B,GAAG,EACH,KAAM,IAAI,IAAS,EAAK,OAAS,IAAM,GAAK,EAAK,OAClD,CAeD,OAdI,EAAK,OACP,EAAS,KAAO,GAAG,EAAK,KAAK,KAAK,KAGhC,EAAK,WACP,EAAS,SAAW,EAAK,SAAS,IAAK,GAAU,CAC/C,IAAM,EAA2B,CAAE,GAAG,EAAO,CAI7C,OAHI,EAAM,OACR,EAAc,KAAO,GAAG,EAAM,KAAK,KAAK,KAEnC,GACP,EAGG"}
|