@fluenti/nuxt 0.3.3 → 0.4.0-rc.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-CAqp_VCN.js → detectors-CBe19LCy.js} +3 -3
- package/dist/detectors-CBe19LCy.js.map +1 -0
- package/dist/detectors-CxhqsYjl.cjs +2 -0
- package/dist/detectors-CxhqsYjl.cjs.map +1 -0
- package/dist/locale-head-CV660rxz.js +97 -0
- package/dist/locale-head-CV660rxz.js.map +1 -0
- package/dist/locale-head-CwFSeJqY.cjs +2 -0
- package/dist/locale-head-CwFSeJqY.cjs.map +1 -0
- package/dist/module.cjs +1 -1
- package/dist/module.cjs.map +1 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +10 -23
- package/dist/module.js.map +1 -1
- package/dist/page-meta-transform.d.ts.map +1 -1
- package/dist/runtime/client.cjs +1 -1
- package/dist/runtime/client.js +1 -1
- package/dist/runtime/composables.cjs +1 -1
- package/dist/runtime/composables.js +1 -1
- package/dist/runtime/index.cjs +1 -1
- package/dist/runtime/index.js +1 -1
- 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.js +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 +1 -7
- package/dist/runtime/plugin.js.map +1 -1
- package/dist/runtime/server/locale-redirect.cjs +1 -1
- package/dist/runtime/server/locale-redirect.cjs.map +1 -1
- package/dist/runtime/server/locale-redirect.d.ts.map +1 -1
- package/dist/runtime/server/locale-redirect.js +5 -5
- package/dist/runtime/server/locale-redirect.js.map +1 -1
- package/dist/runtime/standalone-composables.cjs +1 -1
- package/dist/runtime/standalone-composables.js +1 -1
- package/package.json +3 -3
- package/dist/detectors-BnmzZTww.cjs +0 -2
- package/dist/detectors-BnmzZTww.cjs.map +0 -1
- package/dist/detectors-CAqp_VCN.js.map +0 -1
- package/dist/locale-head-BuSO-fCZ.js +0 -88
- package/dist/locale-head-BuSO-fCZ.js.map +0 -1
- package/dist/locale-head-D1NAUQc8.cjs +0 -2
- package/dist/locale-head-D1NAUQc8.cjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detectors-BnmzZTww.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\n // Prefer pre-read cookie value from plugin (hoisted before await)\n if (ctx.cookieValue !== undefined) {\n if (ctx.cookieValue && ctx.locales.includes(ctx.cookieValue)) {\n ctx.setLocale(ctx.cookieValue)\n }\n return\n }\n\n // Fallback: read cookie directly (works when called synchronously in plugin context)\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\n // Prefer pre-read header from plugin (hoisted before await)\n const acceptLang = ctx.acceptLanguage ?? readAcceptLanguage()\n if (acceptLang) {\n const matched = negotiateLocale(acceptLang, ctx.locales)\n if (matched) {\n ctx.setLocale(matched)\n }\n }\n}\n\nfunction readAcceptLanguage(): string | undefined {\n try {\n const headers = useRequestHeaders(['accept-language'])\n return headers['accept-language']\n } catch {\n return undefined\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, useRuntimeConfig } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\nimport type { FluentNuxtRuntimeConfig } 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 config = useRuntimeConfig().public['fluenti'] as FluentNuxtRuntimeConfig\n const paramKey = config.queryParamKey ?? 'locale'\n const queryLocale = route.query[paramKey] 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'\nimport detectDomain from './domain'\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 domain: detectDomain,\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 host?: string,\n cookieValue?: string | null,\n acceptLanguage?: string,\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 ...(host ? { host } : {}),\n ...(cookieValue != null ? { cookieValue } : {}),\n ...(acceptLanguage ? { acceptLanguage } : {}),\n }\n\n // Attach domains to context for domain detector\n if (config.domains) {\n Object.assign(ctx, { domains: config.domains })\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":"iJAIA,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,OAG3C,GAAI,EAAI,cAAgB,IAAA,GAAW,CAC7B,EAAI,aAAe,EAAI,QAAQ,SAAS,EAAI,YAAY,EAC1D,EAAI,UAAU,EAAI,YAAY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,EACR,MAAO,EACP,OAAQ,EACT,CAOD,eAAsB,EACpB,EACA,EACA,EACA,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,GAChC,GAAI,EAAO,CAAE,OAAM,CAAG,EAAE,CACxB,GAAI,GAAe,KAAyB,EAAE,CAApB,CAAE,cAAa,CACzC,GAAI,EAAiB,CAAE,iBAAgB,CAAG,EAAE,CAC7C,CAGG,EAAO,SACT,OAAO,OAAO,EAAK,CAAE,QAAS,EAAO,QAAS,CAAC,CAIjD,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detectors-CAqp_VCN.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\n // Prefer pre-read cookie value from plugin (hoisted before await)\n if (ctx.cookieValue !== undefined) {\n if (ctx.cookieValue && ctx.locales.includes(ctx.cookieValue)) {\n ctx.setLocale(ctx.cookieValue)\n }\n return\n }\n\n // Fallback: read cookie directly (works when called synchronously in plugin context)\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\n // Prefer pre-read header from plugin (hoisted before await)\n const acceptLang = ctx.acceptLanguage ?? readAcceptLanguage()\n if (acceptLang) {\n const matched = negotiateLocale(acceptLang, ctx.locales)\n if (matched) {\n ctx.setLocale(matched)\n }\n }\n}\n\nfunction readAcceptLanguage(): string | undefined {\n try {\n const headers = useRequestHeaders(['accept-language'])\n return headers['accept-language']\n } catch {\n return undefined\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, useRuntimeConfig } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\nimport type { FluentNuxtRuntimeConfig } 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 config = useRuntimeConfig().public['fluenti'] as FluentNuxtRuntimeConfig\n const paramKey = config.queryParamKey ?? 'locale'\n const queryLocale = route.query[paramKey] 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'\nimport detectDomain from './domain'\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 domain: detectDomain,\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 host?: string,\n cookieValue?: string | null,\n acceptLanguage?: string,\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 ...(host ? { host } : {}),\n ...(cookieValue != null ? { cookieValue } : {}),\n ...(acceptLanguage ? { acceptLanguage } : {}),\n }\n\n // Attach domains to context for domain detector\n if (config.domains) {\n Object.assign(ctx, { domains: config.domains })\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;AAG3C,KAAI,EAAI,gBAAgB,KAAA,GAAW;AACjC,EAAI,EAAI,eAAe,EAAI,QAAQ,SAAS,EAAI,YAAY,IAC1D,EAAI,UAAU,EAAI,YAAY;AAEhC;;CAIF,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;;;;AClBV,SAAwB,EAAa,GAAgC;AACnE,KAAI,CAAC,EAAI,SAAU;CAGnB,IAAM,IAAa,EAAI,kBAAkB,GAAoB;AAC7D,KAAI,GAAY;EACd,IAAM,IAAU,EAAgB,GAAY,EAAI,QAAQ;AACxD,EAAI,KACF,EAAI,UAAU,EAAQ;;;AAK5B,SAAS,IAAyC;AAChD,KAAI;AAEF,SADgB,EAAkB,CAAC,kBAAkB,CAAC,CACvC;SACT;AACN;;;AAIJ,SAAS,EAAgB,GAAwB,GAAkC;CACjF,IAAM,IAAY,EACf,MAAM,IAAI,CACV,KAAK,MAAS;EACb,IAAM,CAAC,GA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S,EAAO,SAAS,CAAC;AAIjD,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,88 +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 = r.localeProperties?.[t], o = a?.iso ?? t, s = {
|
|
5
|
-
htmlAttrs: {
|
|
6
|
-
lang: o,
|
|
7
|
-
...a?.dir ? { dir: a.dir } : {}
|
|
8
|
-
},
|
|
9
|
-
link: [],
|
|
10
|
-
meta: []
|
|
11
|
-
};
|
|
12
|
-
if (i?.addSeoAttributes) {
|
|
13
|
-
let a = i.baseUrl ?? "";
|
|
14
|
-
for (let t of r.locales) {
|
|
15
|
-
let i = r.localeProperties?.[t]?.iso ?? t;
|
|
16
|
-
if (r.strategy === "domains" && r.domains?.length) {
|
|
17
|
-
let e = r.domains.find((e) => e.locale === t);
|
|
18
|
-
if (e) {
|
|
19
|
-
let t = a.startsWith("https") ? "https" : "http";
|
|
20
|
-
s.link.push({
|
|
21
|
-
rel: "alternate",
|
|
22
|
-
hreflang: i,
|
|
23
|
-
href: `${t}://${e.domain}${n}`
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
} else {
|
|
27
|
-
let o = e(n, t, r.locales, r.defaultLocale, r.strategy);
|
|
28
|
-
s.link.push({
|
|
29
|
-
rel: "alternate",
|
|
30
|
-
hreflang: i,
|
|
31
|
-
href: `${a}${o}`
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (r.strategy === "domains" && r.domains?.length) {
|
|
36
|
-
let e = r.domains.find((e) => e.locale === r.defaultLocale);
|
|
37
|
-
if (e) {
|
|
38
|
-
let t = a.startsWith("https") ? "https" : "http";
|
|
39
|
-
s.link.push({
|
|
40
|
-
rel: "alternate",
|
|
41
|
-
hreflang: "x-default",
|
|
42
|
-
href: `${t}://${e.domain}${n}`
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
let t = e(n, r.defaultLocale, r.locales, r.defaultLocale, r.strategy);
|
|
47
|
-
s.link.push({
|
|
48
|
-
rel: "alternate",
|
|
49
|
-
hreflang: "x-default",
|
|
50
|
-
href: `${a}${t}`
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
if (i.addCanonical !== !1) if (r.strategy === "domains" && r.domains?.length) {
|
|
54
|
-
let e = r.domains.find((e) => e.locale === t);
|
|
55
|
-
if (e) {
|
|
56
|
-
let t = a.startsWith("https") ? "https" : "http";
|
|
57
|
-
s.link.push({
|
|
58
|
-
rel: "canonical",
|
|
59
|
-
hreflang: "",
|
|
60
|
-
href: `${t}://${e.domain}${n}`
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
let i = e(n, t, r.locales, r.defaultLocale, r.strategy);
|
|
65
|
-
s.link.push({
|
|
66
|
-
rel: "canonical",
|
|
67
|
-
hreflang: "",
|
|
68
|
-
href: `${a}${i}`
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
s.meta.push({
|
|
72
|
-
property: "og:locale",
|
|
73
|
-
content: o
|
|
74
|
-
});
|
|
75
|
-
for (let e of r.locales) if (e !== t) {
|
|
76
|
-
let t = r.localeProperties?.[e];
|
|
77
|
-
s.meta.push({
|
|
78
|
-
property: "og:locale:alternate",
|
|
79
|
-
content: t?.iso ?? e
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return s;
|
|
84
|
-
}
|
|
85
|
-
//#endregion
|
|
86
|
-
export { t };
|
|
87
|
-
|
|
88
|
-
//# sourceMappingURL=locale-head-BuSO-fCZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"locale-head-BuSO-fCZ.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; dir?: 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 /** Add a canonical link tag for the current page (default: true when addSeoAttributes is true) */\n addCanonical?: boolean\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 props = config.localeProperties?.[locale]\n const isoTag = props?.iso ?? locale\n\n const head: LocaleHeadMeta = {\n htmlAttrs: {\n lang: isoTag,\n ...(props?.dir ? { dir: props.dir } : {}),\n },\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 locProps = config.localeProperties?.[loc]\n const locIso = locProps?.iso ?? loc\n\n if (config.strategy === 'domains' && config.domains?.length) {\n // For domain strategy, build absolute URLs using domain configs\n const domainEntry = config.domains.find((d) => d.locale === loc)\n if (domainEntry) {\n const protocol = baseUrl.startsWith('https') ? 'https' : 'http'\n head.link.push({\n rel: 'alternate',\n hreflang: locIso,\n href: `${protocol}://${domainEntry.domain}${currentPath}`,\n })\n }\n } else {\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: locIso,\n href: `${baseUrl}${path}`,\n })\n }\n }\n\n // x-default hreflang\n if (config.strategy === 'domains' && config.domains?.length) {\n const defaultDomain = config.domains.find((d) => d.locale === config.defaultLocale)\n if (defaultDomain) {\n const protocol = baseUrl.startsWith('https') ? 'https' : 'http'\n head.link.push({\n rel: 'alternate',\n hreflang: 'x-default',\n href: `${protocol}://${defaultDomain.domain}${currentPath}`,\n })\n }\n } else {\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\n // Canonical link tag (defaults to true when addSeoAttributes is enabled)\n if (options.addCanonical !== false) {\n if (config.strategy === 'domains' && config.domains?.length) {\n const domainEntry = config.domains.find((d) => d.locale === locale)\n if (domainEntry) {\n const protocol = baseUrl.startsWith('https') ? 'https' : 'http'\n head.link.push({\n rel: 'canonical',\n hreflang: '',\n href: `${protocol}://${domainEntry.domain}${currentPath}`,\n })\n }\n } else {\n const canonicalPath = switchLocalePath(\n currentPath,\n locale,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n head.link.push({\n rel: 'canonical',\n hreflang: '',\n href: `${baseUrl}${canonicalPath}`,\n })\n }\n }\n\n // og:locale (use ISO tag if available)\n head.meta.push({ property: 'og:locale', content: isoTag })\n\n // og:locale:alternate for other locales\n for (const loc of config.locales) {\n if (loc !== locale) {\n const locProps = config.localeProperties?.[loc]\n head.meta.push({\n property: 'og:locale:alternate',\n content: locProps?.iso ?? loc,\n })\n }\n }\n }\n\n return head\n}\n"],"mappings":";;AAyBA,SAAgB,EACd,GACA,GACA,GACA,GACgB;CAChB,IAAM,IAAQ,EAAO,mBAAmB,IAClC,IAAS,GAAO,OAAO,GAEvB,IAAuB;EAC3B,WAAW;GACT,MAAM;GACN,GAAI,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AM,EAAE,WAAW,EAAO;AACnE,OAAI,GAAa;IACf,IAAM,IAAW,EAAQ,WAAW,QAAQ,GAAG,UAAU;AACzD,MAAK,KAAK,KAAK;KACb,KAAK;KACL,UAAU;KACV,MAAM,GAAG,EAAS,KAAK,EAAY,SAAS;KAC7C,CAAC;;SAEC;GACL,IAAM,IAAgB,EACpB,GACA,GACA,EAAO,SACP,EAAO,eACP,EAAO,SACR;AACD,KAAK,KAAK,KAAK;IACb,KAAK;IACL,UAAU;IACV,MAAM,GAAG,IAAU;IACpB,CAAC;;AAKN,IAAK,KAAK,KAAK;GAAE,UAAU;GAAa,SAAS;GAAQ,CAAC;AAG1D,OAAK,IAAM,KAAO,EAAO,QACvB,KAAI,MAAQ,GAAQ;GAClB,IAAM,IAAW,EAAO,mBAAmB;AAC3C,KAAK,KAAK,KAAK;IACb,UAAU;IACV,SAAS,GAAU,OAAO;IAC3B,CAAC;;;AAKR,QAAO"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require(`./path-utils-BQIsp_or.cjs`);function t(t,n,r,i){let a=r.localeProperties?.[t],o=a?.iso??t,s={htmlAttrs:{lang:o,...a?.dir?{dir:a.dir}:{}},link:[],meta:[]};if(i?.addSeoAttributes){let a=i.baseUrl??``;for(let t of r.locales){let i=r.localeProperties?.[t]?.iso??t;if(r.strategy===`domains`&&r.domains?.length){let e=r.domains.find(e=>e.locale===t);if(e){let t=a.startsWith(`https`)?`https`:`http`;s.link.push({rel:`alternate`,hreflang:i,href:`${t}://${e.domain}${n}`})}}else{let o=e.r(n,t,r.locales,r.defaultLocale,r.strategy);s.link.push({rel:`alternate`,hreflang:i,href:`${a}${o}`})}}if(r.strategy===`domains`&&r.domains?.length){let e=r.domains.find(e=>e.locale===r.defaultLocale);if(e){let t=a.startsWith(`https`)?`https`:`http`;s.link.push({rel:`alternate`,hreflang:`x-default`,href:`${t}://${e.domain}${n}`})}}else{let t=e.r(n,r.defaultLocale,r.locales,r.defaultLocale,r.strategy);s.link.push({rel:`alternate`,hreflang:`x-default`,href:`${a}${t}`})}if(i.addCanonical!==!1)if(r.strategy===`domains`&&r.domains?.length){let e=r.domains.find(e=>e.locale===t);if(e){let t=a.startsWith(`https`)?`https`:`http`;s.link.push({rel:`canonical`,hreflang:``,href:`${t}://${e.domain}${n}`})}}else{let i=e.r(n,t,r.locales,r.defaultLocale,r.strategy);s.link.push({rel:`canonical`,hreflang:``,href:`${a}${i}`})}s.meta.push({property:`og:locale`,content:o});for(let e of r.locales)if(e!==t){let t=r.localeProperties?.[e];s.meta.push({property:`og:locale:alternate`,content:t?.iso??e})}}return s}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
2
|
-
//# sourceMappingURL=locale-head-D1NAUQc8.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"locale-head-D1NAUQc8.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; dir?: 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 /** Add a canonical link tag for the current page (default: true when addSeoAttributes is true) */\n addCanonical?: boolean\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 props = config.localeProperties?.[locale]\n const isoTag = props?.iso ?? locale\n\n const head: LocaleHeadMeta = {\n htmlAttrs: {\n lang: isoTag,\n ...(props?.dir ? { dir: props.dir } : {}),\n },\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 locProps = config.localeProperties?.[loc]\n const locIso = locProps?.iso ?? loc\n\n if (config.strategy === 'domains' && config.domains?.length) {\n // For domain strategy, build absolute URLs using domain configs\n const domainEntry = config.domains.find((d) => d.locale === loc)\n if (domainEntry) {\n const protocol = baseUrl.startsWith('https') ? 'https' : 'http'\n head.link.push({\n rel: 'alternate',\n hreflang: locIso,\n href: `${protocol}://${domainEntry.domain}${currentPath}`,\n })\n }\n } else {\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: locIso,\n href: `${baseUrl}${path}`,\n })\n }\n }\n\n // x-default hreflang\n if (config.strategy === 'domains' && config.domains?.length) {\n const defaultDomain = config.domains.find((d) => d.locale === config.defaultLocale)\n if (defaultDomain) {\n const protocol = baseUrl.startsWith('https') ? 'https' : 'http'\n head.link.push({\n rel: 'alternate',\n hreflang: 'x-default',\n href: `${protocol}://${defaultDomain.domain}${currentPath}`,\n })\n }\n } else {\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\n // Canonical link tag (defaults to true when addSeoAttributes is enabled)\n if (options.addCanonical !== false) {\n if (config.strategy === 'domains' && config.domains?.length) {\n const domainEntry = config.domains.find((d) => d.locale === locale)\n if (domainEntry) {\n const protocol = baseUrl.startsWith('https') ? 'https' : 'http'\n head.link.push({\n rel: 'canonical',\n hreflang: '',\n href: `${protocol}://${domainEntry.domain}${currentPath}`,\n })\n }\n } else {\n const canonicalPath = switchLocalePath(\n currentPath,\n locale,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n head.link.push({\n rel: 'canonical',\n hreflang: '',\n href: `${baseUrl}${canonicalPath}`,\n })\n }\n }\n\n // og:locale (use ISO tag if available)\n head.meta.push({ property: 'og:locale', content: isoTag })\n\n // og:locale:alternate for other locales\n for (const loc of config.locales) {\n if (loc !== locale) {\n const locProps = config.localeProperties?.[loc]\n head.meta.push({\n property: 'og:locale:alternate',\n content: locProps?.iso ?? loc,\n })\n }\n }\n }\n\n return head\n}\n"],"mappings":"6CAyBA,SAAgB,EACd,EACA,EACA,EACA,EACgB,CAChB,IAAM,EAAQ,EAAO,mBAAmB,GAClC,EAAS,GAAO,KAAO,EAEvB,EAAuB,CAC3B,UAAW,CACT,KAAM,EACN,GAAI,GAAO,IAAM,CAAE,IAAK,EAAM,IAAK,CAAG,EAAE,CACzC,CACD,KAAM,EAAE,CACR,KAAM,EAAE,CACT,CAED,GAAI,GAAS,iBAAkB,CAC7B,IAAM,EAAU,EAAQ,SAAW,GAGnC,IAAK,IAAM,KAAO,EAAO,QAAS,CAEhC,IAAM,EADW,EAAO,mBAAmB,IAClB,KAAO,EAEhC,GAAI,EAAO,WAAa,WAAa,EAAO,SAAS,OAAQ,CAE3D,IAAM,EAAc,EAAO,QAAQ,KAAM,GAAM,EAAE,SAAW,EAAI,CAChE,GAAI,EAAa,CACf,IAAM,EAAW,EAAQ,WAAW,QAAQ,CAAG,QAAU,OACzD,EAAK,KAAK,KAAK,CACb,IAAK,YACL,SAAU,EACV,KAAM,GAAG,EAAS,KAAK,EAAY,SAAS,IAC7C,CAAC,MAEC,CACL,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,EAKN,GAAI,EAAO,WAAa,WAAa,EAAO,SAAS,OAAQ,CAC3D,IAAM,EAAgB,EAAO,QAAQ,KAAM,GAAM,EAAE,SAAW,EAAO,cAAc,CAC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