@i18n-micro/vitepress 1.1.14 → 2.0.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/LICENSE +1 -1
- package/README.md +13 -91
- package/dist/adapter-BbqZKi2F.cjs +2 -0
- package/dist/adapter-BbqZKi2F.cjs.map +1 -0
- package/dist/adapter-DTS0CTC7.js +131 -0
- package/dist/adapter-DTS0CTC7.js.map +1 -0
- package/dist/config.cjs +6 -6
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +7 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.mjs +129 -220
- package/dist/config.mjs.map +1 -1
- package/dist/create-Bo6VND8l.js +87 -0
- package/dist/create-Bo6VND8l.js.map +1 -0
- package/dist/create-Dn1m6fyc.cjs +2 -0
- package/dist/create-Dn1m6fyc.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.mjs +6 -7
- package/dist/index.mjs.map +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.cjs.map +1 -1
- package/dist/node.mjs +3 -4
- package/dist/theme.cjs +1 -1
- package/dist/theme.cjs.map +1 -1
- package/dist/theme.d.cts +42 -1
- package/dist/theme.d.ts +42 -1
- package/dist/theme.mjs +9 -7
- package/dist/theme.mjs.map +1 -1
- package/dist/vitepress-locales-CwOlvAa0.cjs.map +1 -1
- package/dist/{vitepress-locales-DOhKs3q5.js → vitepress-locales-DYuP6i_x.js} +2 -3
- package/dist/{vitepress-locales-DOhKs3q5.js.map → vitepress-locales-DYuP6i_x.js.map} +1 -1
- package/package.json +24 -13
- package/dist/adapter-CAJNI6Sw.js +0 -127
- package/dist/adapter-CAJNI6Sw.js.map +0 -1
- package/dist/adapter-eYZZOC9d.cjs +0 -2
- package/dist/adapter-eYZZOC9d.cjs.map +0 -1
- package/dist/create-C_dXg23X.js +0 -81
- package/dist/create-C_dXg23X.js.map +0 -1
- package/dist/create-Cwu2djcO.cjs +0 -2
- package/dist/create-Cwu2djcO.cjs.map +0 -1
- package/dist/plugin/virtual-stubs/config.d.cts +0 -14
- package/dist/runtime/define-theme.d.cts +0 -39
package/dist/config.mjs
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { i as e, n as t } from "./adapter-
|
|
2
|
-
import { t as n } from "./vitepress-locales-
|
|
3
|
-
import {
|
|
4
|
-
import { existsSync as a
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { i as e, n as t } from "./adapter-DTS0CTC7.js";
|
|
2
|
+
import { t as n } from "./vitepress-locales-DYuP6i_x.js";
|
|
3
|
+
import { buildLocaleHead as r, filterQuery as i } from "@i18n-micro/utils/locale-head";
|
|
4
|
+
import { existsSync as a } from "node:fs";
|
|
5
|
+
import { resolve as o } from "node:path";
|
|
6
|
+
import { classifyTranslationRelativePath as s } from "@i18n-micro/utils/parse-path";
|
|
7
|
+
import { listTranslationFiles as c, loadTranslationDir as l } from "@i18n-micro/utils/load-dir";
|
|
8
|
+
new Set("xml txt ico json js css png jpg jpeg gif svg webp avif pdf wasm map mp4 webm mp3 zip gz woff woff2 ttf eot".split(" "));
|
|
9
|
+
var u = (e) => e.includes("\\") ? e.split("\\").join("/") : e;
|
|
10
|
+
// src/router/i18n-routing.ts
|
|
11
|
+
function d(e) {
|
|
10
12
|
return "switchLocalePath" in e && typeof e.switchLocalePath == "function";
|
|
11
13
|
}
|
|
12
|
-
function
|
|
13
|
-
let t =
|
|
14
|
+
function f(e) {
|
|
15
|
+
let t = d(e) ? {
|
|
14
16
|
defaultLocale: e.defaultLocale,
|
|
15
17
|
localeCodes: e.localeCodes,
|
|
16
18
|
localeKeyToCode: e.localeKeyToCode ?? {},
|
|
@@ -68,199 +70,108 @@ function _(e) {
|
|
|
68
70
|
return localized + extras + q + h;
|
|
69
71
|
`);
|
|
70
72
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
n >= 0 && (i = Math.min(i, n)), r >= 0 && (i = Math.min(i, r));
|
|
76
|
-
let a = e.slice(0, i) || "/";
|
|
77
|
-
if (r < 0 || t.length === 0) return a;
|
|
78
|
-
let o = new URLSearchParams(e.slice(r, n >= 0 ? n : void 0)), s = new URLSearchParams();
|
|
79
|
-
for (let e of t) o.has(e) && s.set(e, o.get(e));
|
|
80
|
-
let c = s.toString();
|
|
81
|
-
return c ? `${a}?${c}` : a;
|
|
73
|
+
// src/seo/locale-head.ts
|
|
74
|
+
var p = (e) => e.endsWith("/") ? e.slice(0, -1) : e;
|
|
75
|
+
function m(e, t, n) {
|
|
76
|
+
return `${p(e)}${!t || t === "/" ? "" : p(t)}${n.startsWith("/") ? n : `/${n}`}`;
|
|
82
77
|
}
|
|
83
|
-
function
|
|
84
|
-
|
|
78
|
+
function h(e) {
|
|
79
|
+
let t = u(e);
|
|
80
|
+
return t === "index.md" || t.endsWith("/index.md") ? t = t.slice(0, -8) : t.endsWith(".md") && (t = t.slice(0, -3)), t.startsWith("/") || (t = `/${t}`), t.length > 1 && t.endsWith("/") && (t = t.slice(0, -1)), t || "/";
|
|
85
81
|
}
|
|
86
|
-
function
|
|
87
|
-
let
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
function x(n) {
|
|
91
|
-
let { locales: r, defaultLocale: i, localeKeyToCode: a = {}, base: o, metaBaseUrl: s, hreflangBaseLanguage: c = !1, canonicalQueryWhitelist: l = [], addDirAttribute: u = !0, addSeoAttributes: d = !0, identifierAttribute: f = "id", missingWarn: g = !0 } = n, b = e(n.path, o), x = t(b, r.map((e) => e.code), i, a, void 0), S = r.find((e) => e.code === x);
|
|
92
|
-
if (!S) return {
|
|
82
|
+
function g(n) {
|
|
83
|
+
let { locales: a, defaultLocale: o, localeKeyToCode: s = {}, base: c, metaBaseUrl: l, hreflangBaseLanguage: u = !1, canonicalQueryWhitelist: d = [], addDirAttribute: p = !0, addSeoAttributes: h = !0, identifierAttribute: g = "id", missingWarn: _ = !0 } = n, v = e(n.path, c), y = t(v, a.map((e) => e.code), o, s, void 0), b = a.find((e) => e.code === y);
|
|
84
|
+
if (!b) return {
|
|
93
85
|
htmlAttrs: {},
|
|
94
86
|
head: []
|
|
95
87
|
};
|
|
96
|
-
let
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
88
|
+
let x = f({
|
|
89
|
+
defaultLocale: o,
|
|
90
|
+
localeCodes: a.map((e) => e.code),
|
|
91
|
+
localeKeyToCode: s,
|
|
92
|
+
base: c
|
|
93
|
+
}), S = i(v, d), C = (e) => m(l ?? "", c, x({}, { path: S }, e)), w = (e, t) => {
|
|
94
|
+
if (e === o) return "root";
|
|
95
|
+
let n = Object.entries(s).find(([, t]) => t === e);
|
|
96
|
+
return n ? n[0] === "root" ? t : n[0] : e;
|
|
97
|
+
}, T = a.filter((e) => !e.disabled && e.seo !== !1), { htmlAttrs: E, link: D, meta: O } = r({
|
|
98
|
+
locale: b,
|
|
99
|
+
seoLocales: T,
|
|
100
|
+
hrefOf: (e) => C(w(e, e)),
|
|
101
|
+
canonical: C(w(y, "root")),
|
|
102
|
+
xDefault: T.some((e) => e.code === o) ? C("root") : void 0,
|
|
103
|
+
addDirAttribute: p,
|
|
104
|
+
addSeoAttributes: h && !!l,
|
|
105
|
+
identifierAttribute: g,
|
|
106
|
+
hreflangBaseLanguage: u,
|
|
107
|
+
missingWarn: _
|
|
108
|
+
});
|
|
109
|
+
if (D.length === 0) return {
|
|
110
|
+
htmlAttrs: E,
|
|
102
111
|
head: []
|
|
103
112
|
};
|
|
104
|
-
let
|
|
105
|
-
defaultLocale: i,
|
|
106
|
-
localeCodes: r.map((e) => e.code),
|
|
107
|
-
localeKeyToCode: a,
|
|
108
|
-
base: o
|
|
109
|
-
}), D = v(b, l), O = x === i ? "root" : (() => {
|
|
110
|
-
for (let [e, t] of Object.entries(a)) if (t === x) return e === "root" ? "root" : e;
|
|
111
|
-
return x;
|
|
112
|
-
})(), k = y(s, o, E({}, { path: D }, O)), A = r.filter((e) => !e.disabled && e.seo !== !1), j = m(S);
|
|
113
|
-
j || h(S, {
|
|
114
|
-
missingWarn: g,
|
|
115
|
-
tag: "og:locale"
|
|
116
|
-
});
|
|
117
|
-
let M = [];
|
|
118
|
-
M.push(["link", {
|
|
119
|
-
[f]: "i18n-can",
|
|
120
|
-
rel: "canonical",
|
|
121
|
-
href: k
|
|
122
|
-
}]), j && M.push(["meta", {
|
|
123
|
-
[f]: "i18n-og",
|
|
124
|
-
property: "og:locale",
|
|
125
|
-
content: j
|
|
126
|
-
}]), M.push(["meta", {
|
|
127
|
-
[f]: "i18n-og-url",
|
|
128
|
-
property: "og:url",
|
|
129
|
-
content: k
|
|
130
|
-
}]);
|
|
131
|
-
for (let e of A) {
|
|
132
|
-
if (e.code === x) continue;
|
|
133
|
-
let t = m(e);
|
|
134
|
-
if (!t) {
|
|
135
|
-
h(e, {
|
|
136
|
-
missingWarn: g,
|
|
137
|
-
tag: "og:locale:alternate"
|
|
138
|
-
});
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
M.push(["meta", {
|
|
142
|
-
[f]: `i18n-og-alt-${t}`,
|
|
143
|
-
property: "og:locale:alternate",
|
|
144
|
-
content: t
|
|
145
|
-
}]);
|
|
146
|
-
}
|
|
147
|
-
let N = /* @__PURE__ */ new Map();
|
|
148
|
-
for (let e of A) {
|
|
149
|
-
let t = e.code === i ? "root" : (() => {
|
|
150
|
-
for (let [t, n] of Object.entries(a)) if (n === e.code) return t === "root" ? e.code : t;
|
|
151
|
-
return e.code;
|
|
152
|
-
})(), n = E({}, { path: D }, t);
|
|
153
|
-
n && N.set(String(e.code), y(s, o, n));
|
|
154
|
-
}
|
|
155
|
-
for (let { hreflang: e, localeCode: t } of p(A, { hreflangBaseLanguage: c })) {
|
|
156
|
-
let n = N.get(t);
|
|
157
|
-
n && M.push(["link", {
|
|
158
|
-
[f]: `i18n-alternate-${e}`,
|
|
159
|
-
rel: "alternate",
|
|
160
|
-
href: n,
|
|
161
|
-
hreflang: e
|
|
162
|
-
}]);
|
|
163
|
-
}
|
|
164
|
-
let P = r.find((e) => e.code === i);
|
|
165
|
-
if (P && P.seo !== !1) {
|
|
166
|
-
let e = N.get(i);
|
|
167
|
-
e && M.push(["link", {
|
|
168
|
-
[f]: "i18n-xd",
|
|
169
|
-
rel: "alternate",
|
|
170
|
-
href: e,
|
|
171
|
-
hreflang: "x-default"
|
|
172
|
-
}]);
|
|
173
|
-
}
|
|
113
|
+
let [k, ...A] = D, j = (e, t) => t.map((t) => [e, t]);
|
|
174
114
|
return {
|
|
175
|
-
htmlAttrs:
|
|
176
|
-
head:
|
|
115
|
+
htmlAttrs: E,
|
|
116
|
+
head: [
|
|
117
|
+
...j("link", [k]),
|
|
118
|
+
...j("meta", O),
|
|
119
|
+
...j("link", A)
|
|
120
|
+
]
|
|
177
121
|
};
|
|
178
122
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
function
|
|
182
|
-
|
|
183
|
-
let r = l(e, n);
|
|
184
|
-
if (c(r).isDirectory()) {
|
|
185
|
-
S(r, t);
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
n.endsWith(".json") && t(r);
|
|
189
|
-
}
|
|
123
|
+
// src/plugin/load-messages.ts
|
|
124
|
+
var _ = (e) => o(e.rootDir ?? process.cwd(), e.translationDir);
|
|
125
|
+
function v(e) {
|
|
126
|
+
return c(_(e));
|
|
190
127
|
}
|
|
191
|
-
function
|
|
192
|
-
|
|
193
|
-
return S(n, (e) => {
|
|
194
|
-
r.push({
|
|
195
|
-
absolutePath: e,
|
|
196
|
-
relativePath: u(n, e).split(f).join("/")
|
|
197
|
-
});
|
|
198
|
-
}), r.sort((e, t) => e.relativePath.localeCompare(t.relativePath));
|
|
128
|
+
function y(e) {
|
|
129
|
+
return l(_(e), e.disablePageLocales === !0);
|
|
199
130
|
}
|
|
131
|
+
// src/plugin/with-i18n.ts
|
|
132
|
+
var b = "virtual:i18n-micro/config", x = `\0${b}`, S = "virtual:i18n-micro/messages", C = `\0${S}`;
|
|
200
133
|
function w(e) {
|
|
201
|
-
|
|
202
|
-
root: {},
|
|
203
|
-
routes: {}
|
|
204
|
-
}, s = e.disablePageLocales === !0;
|
|
205
|
-
return a(n) && S(n, (e) => {
|
|
206
|
-
let t = u(n, e).split(f).join("/");
|
|
207
|
-
try {
|
|
208
|
-
let n = JSON.parse(o(e, "utf-8"));
|
|
209
|
-
if (typeof n != "object" || !n || Array.isArray(n)) {
|
|
210
|
-
console.error(`[i18n-micro/vitepress] Skipping ${t}: expected a JSON object, got ${Array.isArray(n) ? "array" : typeof n}`);
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
i(r, t, n, s);
|
|
214
|
-
} catch (e) {
|
|
215
|
-
console.error(`[i18n-micro/vitepress] Failed to load ${t}:`, e);
|
|
216
|
-
}
|
|
217
|
-
}), r;
|
|
134
|
+
return u(e);
|
|
218
135
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
var T = "virtual:i18n-micro/config", E = `\0${T}`, D = "virtual:i18n-micro/messages", O = `\0${D}`;
|
|
222
|
-
function k(e) {
|
|
223
|
-
return e.replace(/\\/g, "/");
|
|
224
|
-
}
|
|
225
|
-
function A(e, t, n) {
|
|
226
|
-
let i = C({
|
|
136
|
+
function T(e, t, n) {
|
|
137
|
+
let r = v({
|
|
227
138
|
rootDir: e,
|
|
228
139
|
translationDir: t
|
|
229
140
|
});
|
|
230
|
-
if (
|
|
231
|
-
let
|
|
232
|
-
for (let e of
|
|
233
|
-
let t =
|
|
141
|
+
if (r.length === 0) return "export const messages = {}\nexport const routeMessages = {}\n";
|
|
142
|
+
let i = [], a = [], o = /* @__PURE__ */ new Map(), c = 0;
|
|
143
|
+
for (let e of r) {
|
|
144
|
+
let t = s(e.relativePath, n);
|
|
234
145
|
if (t.type === "ignore") continue;
|
|
235
|
-
let
|
|
236
|
-
if (
|
|
237
|
-
|
|
146
|
+
let r = `__i18n_${c++}`;
|
|
147
|
+
if (i.push(`import ${r} from ${JSON.stringify(w(e.absolutePath))}`), t.type === "root") {
|
|
148
|
+
a.push(` ${JSON.stringify(t.locale)}: ${r}`);
|
|
238
149
|
continue;
|
|
239
150
|
}
|
|
240
|
-
let l =
|
|
241
|
-
l || (l = /* @__PURE__ */ new Map(),
|
|
151
|
+
let l = o.get(t.pageName);
|
|
152
|
+
l || (l = /* @__PURE__ */ new Map(), o.set(t.pageName, l)), l.set(t.locale, r);
|
|
242
153
|
}
|
|
243
154
|
let l = [];
|
|
244
|
-
for (let [e, t] of
|
|
155
|
+
for (let [e, t] of o) {
|
|
245
156
|
let n = [...t.entries()].map(([e, t]) => ` ${JSON.stringify(e)}: ${t}`).join(",\n");
|
|
246
157
|
l.push(` ${JSON.stringify(e)}: {\n${n}\n }`);
|
|
247
158
|
}
|
|
248
159
|
return [
|
|
249
|
-
...
|
|
250
|
-
`export const messages = {\n${
|
|
160
|
+
...i,
|
|
161
|
+
`export const messages = {\n${a.join(",\n")}\n}`,
|
|
251
162
|
`export const routeMessages = {\n${l.join(",\n")}\n}`,
|
|
252
163
|
""
|
|
253
164
|
].join("\n");
|
|
254
165
|
}
|
|
255
|
-
function
|
|
166
|
+
function E(e, t) {
|
|
256
167
|
return [
|
|
257
168
|
`export const messages = ${JSON.stringify(e)}`,
|
|
258
169
|
`export const routeMessages = ${JSON.stringify(t)}`,
|
|
259
170
|
""
|
|
260
171
|
].join("\n");
|
|
261
172
|
}
|
|
262
|
-
function
|
|
263
|
-
let n = e.defaultLocale || e.locale, r = e.translationDir ?? "locales", i = e.disablePageLocales === !0,
|
|
173
|
+
function D(e, t) {
|
|
174
|
+
let n = e.defaultLocale || e.locale, r = e.translationDir ?? "locales", i = e.disablePageLocales === !0, s = {
|
|
264
175
|
defaultLocale: n,
|
|
265
176
|
fallbackLocale: e.fallbackLocale || n,
|
|
266
177
|
locales: e.locales || [],
|
|
@@ -270,30 +181,33 @@ function M(e, t) {
|
|
|
270
181
|
translationDir: r,
|
|
271
182
|
disablePageLocales: i,
|
|
272
183
|
localeKeyToCode: e.localeKeyToCode ?? {},
|
|
273
|
-
base: t && t !== "/" ? t : void 0
|
|
274
|
-
|
|
184
|
+
base: t && t !== "/" ? t : void 0,
|
|
185
|
+
numberFormats: e.numberFormats,
|
|
186
|
+
datetimeFormats: e.datetimeFormats,
|
|
187
|
+
timeZone: e.timeZone
|
|
188
|
+
}, c = process.cwd(), l = !!(e.messages || e.routeMessages), u = e.messages ?? {}, d = e.routeMessages ?? {}, f, p = () => !e.messages || !e.routeMessages, m = () => {
|
|
275
189
|
if (!p()) return;
|
|
276
|
-
let t =
|
|
277
|
-
rootDir:
|
|
190
|
+
let t = y({
|
|
191
|
+
rootDir: c,
|
|
278
192
|
translationDir: r,
|
|
279
193
|
disablePageLocales: i
|
|
280
194
|
});
|
|
281
|
-
e.messages || (
|
|
195
|
+
e.messages || (u = t.root), e.routeMessages || (d = t.routes);
|
|
282
196
|
};
|
|
283
197
|
return {
|
|
284
198
|
name: "vite-plugin-i18n-vitepress",
|
|
285
|
-
configResolved(
|
|
286
|
-
|
|
199
|
+
configResolved(e) {
|
|
200
|
+
c = e.root, l && m();
|
|
287
201
|
},
|
|
288
202
|
configureServer(e) {
|
|
289
|
-
if (
|
|
290
|
-
let t =
|
|
203
|
+
if (l && !p()) return;
|
|
204
|
+
let t = o(c, r);
|
|
291
205
|
if (!a(t)) return;
|
|
292
206
|
e.watcher.add(t);
|
|
293
207
|
let n = () => {
|
|
294
208
|
f && clearTimeout(f), f = setTimeout(() => {
|
|
295
|
-
|
|
296
|
-
let t = e.moduleGraph.getModuleById(
|
|
209
|
+
l && m();
|
|
210
|
+
let t = e.moduleGraph.getModuleById(C);
|
|
297
211
|
t && (e.moduleGraph.invalidateModule(t), e.ws.send({ type: "full-reload" }));
|
|
298
212
|
}, 50);
|
|
299
213
|
};
|
|
@@ -301,21 +215,21 @@ function M(e, t) {
|
|
|
301
215
|
e.startsWith(t) && e.endsWith(".json") && n();
|
|
302
216
|
}), e.watcher.on("unlink", (e) => {
|
|
303
217
|
e.startsWith(t) && e.endsWith(".json") && n();
|
|
304
|
-
}),
|
|
218
|
+
}), l && p() && e.watcher.on("change", (e) => {
|
|
305
219
|
e.startsWith(t) && e.endsWith(".json") && n();
|
|
306
220
|
});
|
|
307
221
|
},
|
|
308
222
|
resolveId(e) {
|
|
309
|
-
if (e ===
|
|
310
|
-
if (e ===
|
|
223
|
+
if (e === b) return x;
|
|
224
|
+
if (e === S) return C;
|
|
311
225
|
},
|
|
312
226
|
load(e) {
|
|
313
|
-
if (e ===
|
|
314
|
-
if (e ===
|
|
227
|
+
if (e === x) return `export const config = ${JSON.stringify(s)}`;
|
|
228
|
+
if (e === C) return l ? E(u, d) : T(c, r, i);
|
|
315
229
|
}
|
|
316
230
|
};
|
|
317
231
|
}
|
|
318
|
-
function
|
|
232
|
+
function O(e, t) {
|
|
319
233
|
if (t.warnOnLocaleMismatch === !1) return;
|
|
320
234
|
let n = e.locales;
|
|
321
235
|
if (!n || !t.locales?.length) return;
|
|
@@ -325,53 +239,49 @@ function N(e, t) {
|
|
|
325
239
|
a.has(n) || console.warn(`[i18n-micro/vitepress] VitePress locale key "${e}" maps to "${n}", which is not in i18n locales (${[...a].join(", ")}).`);
|
|
326
240
|
}
|
|
327
241
|
}
|
|
328
|
-
function
|
|
329
|
-
|
|
330
|
-
let n = typeof e.base == "string" ? e.base : void 0, r = e.vite?.plugins, i = [...Array.isArray(r) ? r.flat() : [],
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
242
|
+
function k(e, t) {
|
|
243
|
+
O(e, t);
|
|
244
|
+
let n = typeof e.base == "string" ? e.base : void 0, r = e.vite?.plugins, i = [...Array.isArray(r) ? r.flat() : [], D(t, n)], a = e.vite?.ssr, o = a?.noExternal, s = ["@i18n-micro/vitepress", ...Array.isArray(o) ? o : o && o !== !0 ? [o] : []], c = t.defaultLocale || t.locale, l = (t.locales || []).map((e) => e.code), u = e.themeConfig && typeof e.themeConfig == "object" ? e.themeConfig : {}, d = t.i18nRouting !== !1 && u.i18nRouting === void 0 && l.length > 0, p = t.meta ?? !!t.metaBaseUrl, m = t.locales || [], _ = e.transformHead, v = e.transformPageData, y = {
|
|
245
|
+
locales: m,
|
|
246
|
+
defaultLocale: c,
|
|
247
|
+
localeKeyToCode: t.localeKeyToCode,
|
|
248
|
+
metaBaseUrl: t.metaBaseUrl,
|
|
249
|
+
hreflangBaseLanguage: t.hreflangBaseLanguage,
|
|
250
|
+
canonicalQueryWhitelist: t.canonicalQueryWhitelist,
|
|
251
|
+
missingWarn: t.missingWarn
|
|
252
|
+
}, b = p ? async (t) => {
|
|
253
|
+
let n = typeof _ == "function" ? await _(t) : [], r = Array.isArray(n) ? n : [];
|
|
254
|
+
if (t.pageData?.frontmatter?.i18n?.disableMeta === !0) return r;
|
|
255
|
+
let i = t.pageData?.relativePath || "index.md", a = (typeof e.base == "string" ? e.base : void 0) ?? t.siteData?.base ?? t.siteConfig?.site?.base, o = g({
|
|
256
|
+
...y,
|
|
257
|
+
path: h(i),
|
|
258
|
+
base: a
|
|
343
259
|
});
|
|
344
|
-
return [...
|
|
345
|
-
} :
|
|
346
|
-
if (typeof
|
|
347
|
-
let
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
defaultLocale: c,
|
|
351
|
-
localeKeyToCode: t.localeKeyToCode,
|
|
260
|
+
return [...r, ...o.head];
|
|
261
|
+
} : _, x = p ? async (t, n) => {
|
|
262
|
+
if (typeof v == "function" && await v(t, n), t.frontmatter?.i18n?.disableMeta === !0) return;
|
|
263
|
+
let r = g({
|
|
264
|
+
...y,
|
|
265
|
+
path: h(t.relativePath || "index.md"),
|
|
352
266
|
base: typeof e.base == "string" ? e.base : void 0,
|
|
353
|
-
metaBaseUrl: t.metaBaseUrl,
|
|
354
|
-
hreflangBaseLanguage: t.hreflangBaseLanguage,
|
|
355
|
-
canonicalQueryWhitelist: t.canonicalQueryWhitelist,
|
|
356
|
-
missingWarn: t.missingWarn,
|
|
357
267
|
addSeoAttributes: !1
|
|
358
268
|
});
|
|
359
|
-
|
|
360
|
-
} :
|
|
269
|
+
r.htmlAttrs.lang && (t.frontmatter ??= {}, t.frontmatter.lang || (t.frontmatter.lang = r.htmlAttrs.lang));
|
|
270
|
+
} : v;
|
|
361
271
|
return {
|
|
362
272
|
...e,
|
|
363
273
|
...d ? { themeConfig: {
|
|
364
274
|
...u,
|
|
365
|
-
i18nRouting:
|
|
275
|
+
i18nRouting: f({
|
|
366
276
|
defaultLocale: c,
|
|
367
277
|
localeCodes: l,
|
|
368
278
|
localeKeyToCode: t.localeKeyToCode,
|
|
369
279
|
base: n
|
|
370
280
|
})
|
|
371
281
|
} } : {},
|
|
372
|
-
...
|
|
373
|
-
transformHead:
|
|
374
|
-
transformPageData:
|
|
282
|
+
...p ? {
|
|
283
|
+
transformHead: b,
|
|
284
|
+
transformPageData: x
|
|
375
285
|
} : {},
|
|
376
286
|
vite: {
|
|
377
287
|
...e.vite,
|
|
@@ -383,7 +293,6 @@ function P(e, t) {
|
|
|
383
293
|
}
|
|
384
294
|
};
|
|
385
295
|
}
|
|
386
|
-
|
|
387
|
-
export { x as buildVitePressLocaleHead, n as buildVitePressLocales, b as relativePathToRoutePath, N as warnLocaleMismatch, P as withI18n };
|
|
296
|
+
export { g as buildVitePressLocaleHead, n as buildVitePressLocales, h as relativePathToRoutePath, O as warnLocaleMismatch, k as withI18n };
|
|
388
297
|
|
|
389
298
|
//# sourceMappingURL=config.mjs.map
|