@i18n-micro/vitepress 1.1.1 → 1.1.6
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/adapter-CAJNI6Sw.js +127 -0
- package/dist/adapter-CAJNI6Sw.js.map +1 -0
- package/dist/adapter-eYZZOC9d.cjs +2 -0
- package/dist/adapter-eYZZOC9d.cjs.map +1 -0
- package/dist/config.cjs +13 -19
- package/dist/config.cjs.map +1 -1
- package/dist/config.mjs +329 -336
- package/dist/config.mjs.map +1 -1
- package/dist/create-C_dXg23X.js +81 -0
- package/dist/create-C_dXg23X.js.map +1 -0
- package/dist/create-Cwu2djcO.cjs +2 -0
- package/dist/create-Cwu2djcO.cjs.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +20 -31
- package/dist/index.mjs.map +1 -1
- package/dist/node.cjs +2 -2
- package/dist/node.cjs.map +1 -1
- package/dist/node.mjs +22 -25
- package/dist/node.mjs.map +1 -1
- package/dist/theme.cjs +2 -2
- package/dist/theme.cjs.map +1 -1
- package/dist/theme.mjs +35 -34
- package/dist/theme.mjs.map +1 -1
- package/dist/vitepress-locales-CwOlvAa0.cjs +2 -0
- package/dist/vitepress-locales-CwOlvAa0.cjs.map +1 -0
- package/dist/vitepress-locales-DOhKs3q5.js +27 -0
- package/dist/vitepress-locales-DOhKs3q5.js.map +1 -0
- package/package.json +14 -14
- package/dist/adapter-BJ-0ltIc.cjs +0 -2
- package/dist/adapter-BJ-0ltIc.cjs.map +0 -1
- package/dist/adapter-BnsyIKhp.js +0 -128
- package/dist/adapter-BnsyIKhp.js.map +0 -1
- package/dist/create-BgMbe0w1.cjs +0 -2
- package/dist/create-BgMbe0w1.cjs.map +0 -1
- package/dist/create-Dev8Q66O.js +0 -80
- package/dist/create-Dev8Q66O.js.map +0 -1
- package/dist/vitepress-locales-6msv22Sn.js +0 -27
- package/dist/vitepress-locales-6msv22Sn.js.map +0 -1
- package/dist/vitepress-locales-Cz4AutfI.cjs +0 -2
- package/dist/vitepress-locales-Cz4AutfI.cjs.map +0 -1
package/dist/config.mjs
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { i as e, n as t } from "./adapter-CAJNI6Sw.js";
|
|
2
|
+
import { t as n } from "./vitepress-locales-DOhKs3q5.js";
|
|
3
|
+
import { classifyTranslationRelativePath as r, storeLoadedTranslationFile as i } from "@i18n-micro/utils/parse-path";
|
|
4
|
+
import { existsSync as a, readFileSync as o, readdirSync as s, statSync as c } from "node:fs";
|
|
5
|
+
import { join as l, relative as u, resolve as d, sep as f } from "node:path";
|
|
6
|
+
import { resolveHreflangAlternates as p } from "@i18n-micro/utils/resolve-hreflang";
|
|
7
|
+
import { resolveOgLocale as m, warnUnresolvedOgLocale as h } from "@i18n-micro/utils/resolve-og-locale";
|
|
8
|
+
//#region src/router/i18n-routing.ts
|
|
9
|
+
function g(e) {
|
|
10
|
+
return "switchLocalePath" in e && typeof e.switchLocalePath == "function";
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const defaultLocale = ${JSON.stringify(a)};
|
|
24
|
-
const localeCodes = ${JSON.stringify(o)};
|
|
25
|
-
const localeKeyToCode = ${JSON.stringify(s)};
|
|
26
|
-
const siteBase = ${JSON.stringify(l)};
|
|
12
|
+
function _(e) {
|
|
13
|
+
let t = g(e) ? {
|
|
14
|
+
defaultLocale: e.defaultLocale,
|
|
15
|
+
localeCodes: e.localeCodes,
|
|
16
|
+
localeKeyToCode: e.localeKeyToCode ?? {},
|
|
17
|
+
base: e.base
|
|
18
|
+
} : e, n = t.defaultLocale, r = t.localeCodes, i = t.localeKeyToCode ?? {}, a = t.base && t.base !== "/" ? t.base : "";
|
|
19
|
+
return Function("data", "route", "targetLocale", `
|
|
20
|
+
const defaultLocale = ${JSON.stringify(n)};
|
|
21
|
+
const localeCodes = ${JSON.stringify(r)};
|
|
22
|
+
const localeKeyToCode = ${JSON.stringify(i)};
|
|
23
|
+
const siteBase = ${JSON.stringify(a)};
|
|
27
24
|
const keyFromCode = (code) => {
|
|
28
25
|
for (const key of Object.keys(localeKeyToCode)) {
|
|
29
26
|
if (localeKeyToCode[key] === code) return key;
|
|
@@ -69,328 +66,324 @@ function U(e) {
|
|
|
69
66
|
? (hash.charAt(0) === '#' ? hash : '#' + hash)
|
|
70
67
|
: '';
|
|
71
68
|
return localized + extras + q + h;
|
|
72
|
-
`
|
|
73
|
-
);
|
|
69
|
+
`);
|
|
74
70
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/seo/locale-head.ts
|
|
73
|
+
function v(e, t) {
|
|
74
|
+
let n = e.indexOf("#"), r = e.indexOf("?"), i = e.length;
|
|
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;
|
|
86
82
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
return `${o}${s}${l}`;
|
|
83
|
+
function y(e, t, n) {
|
|
84
|
+
return `${e.replace(/\/$/, "")}${!t || t === "/" ? "" : t.replace(/\/$/, "")}${n.startsWith("/") ? n : `/${n}`}`;
|
|
90
85
|
}
|
|
91
|
-
function
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
function b(e) {
|
|
87
|
+
let t = e.replace(/\\/g, "/");
|
|
88
|
+
return t = t.replace(/(^|\/)index\.md$/, "$1").replace(/\.md$/, ""), t.startsWith("/") || (t = `/${t}`), t.length > 1 && t.endsWith("/") && (t = t.slice(0, -1)), t || "/";
|
|
94
89
|
}
|
|
95
|
-
function
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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 {
|
|
93
|
+
htmlAttrs: {},
|
|
94
|
+
head: []
|
|
95
|
+
};
|
|
96
|
+
let C = S.iso || x, w = S.dir || "auto", T = {
|
|
97
|
+
lang: C,
|
|
98
|
+
...u ? { dir: w } : {}
|
|
99
|
+
};
|
|
100
|
+
if (!d || !s) return {
|
|
101
|
+
htmlAttrs: T,
|
|
102
|
+
head: []
|
|
103
|
+
};
|
|
104
|
+
let E = _({
|
|
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
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
htmlAttrs: T,
|
|
176
|
+
head: M
|
|
177
|
+
};
|
|
164
178
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/plugin/load-messages.ts
|
|
181
|
+
function S(e, t) {
|
|
182
|
+
if (a(e)) for (let n of s(e)) {
|
|
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
|
+
}
|
|
175
190
|
}
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
191
|
+
function C(e) {
|
|
192
|
+
let t = e.rootDir ?? process.cwd(), n = d(t, e.translationDir), r = [];
|
|
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));
|
|
184
199
|
}
|
|
185
|
-
function
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
function w(e) {
|
|
201
|
+
let t = e.rootDir ?? process.cwd(), n = d(t, e.translationDir), r = {
|
|
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;
|
|
202
218
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/plugin/with-i18n.ts
|
|
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, "/");
|
|
206
224
|
}
|
|
207
|
-
function
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
`export const messages = {
|
|
237
|
-
${l.join(`,
|
|
238
|
-
`)}
|
|
239
|
-
}`,
|
|
240
|
-
`export const routeMessages = {
|
|
241
|
-
${h.join(`,
|
|
242
|
-
`)}
|
|
243
|
-
}`,
|
|
244
|
-
""
|
|
245
|
-
].join(`
|
|
246
|
-
`);
|
|
225
|
+
function A(e, t, n) {
|
|
226
|
+
let i = C({
|
|
227
|
+
rootDir: e,
|
|
228
|
+
translationDir: t
|
|
229
|
+
});
|
|
230
|
+
if (i.length === 0) return "export const messages = {}\nexport const routeMessages = {}\n";
|
|
231
|
+
let a = [], o = [], s = /* @__PURE__ */ new Map(), c = 0;
|
|
232
|
+
for (let e of i) {
|
|
233
|
+
let t = r(e.relativePath, n);
|
|
234
|
+
if (t.type === "ignore") continue;
|
|
235
|
+
let i = `__i18n_${c++}`;
|
|
236
|
+
if (a.push(`import ${i} from ${JSON.stringify(k(e.absolutePath))}`), t.type === "root") {
|
|
237
|
+
o.push(` ${JSON.stringify(t.locale)}: ${i}`);
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
let l = s.get(t.pageName);
|
|
241
|
+
l || (l = /* @__PURE__ */ new Map(), s.set(t.pageName, l)), l.set(t.locale, i);
|
|
242
|
+
}
|
|
243
|
+
let l = [];
|
|
244
|
+
for (let [e, t] of s) {
|
|
245
|
+
let n = [...t.entries()].map(([e, t]) => ` ${JSON.stringify(e)}: ${t}`).join(",\n");
|
|
246
|
+
l.push(` ${JSON.stringify(e)}: {\n${n}\n }`);
|
|
247
|
+
}
|
|
248
|
+
return [
|
|
249
|
+
...a,
|
|
250
|
+
`export const messages = {\n${o.join(",\n")}\n}`,
|
|
251
|
+
`export const routeMessages = {\n${l.join(",\n")}\n}`,
|
|
252
|
+
""
|
|
253
|
+
].join("\n");
|
|
247
254
|
}
|
|
248
|
-
function
|
|
249
|
-
|
|
250
|
-
`)
|
|
255
|
+
function j(e, t) {
|
|
256
|
+
return [
|
|
257
|
+
`export const messages = ${JSON.stringify(e)}`,
|
|
258
|
+
`export const routeMessages = ${JSON.stringify(t)}`,
|
|
259
|
+
""
|
|
260
|
+
].join("\n");
|
|
251
261
|
}
|
|
252
|
-
function
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (r === w)
|
|
308
|
-
return i ? ie(h, f) : le(n, o, s);
|
|
309
|
-
}
|
|
310
|
-
};
|
|
262
|
+
function M(e, t) {
|
|
263
|
+
let n = e.defaultLocale || e.locale, r = e.translationDir ?? "locales", i = e.disablePageLocales === !0, o = {
|
|
264
|
+
defaultLocale: n,
|
|
265
|
+
fallbackLocale: e.fallbackLocale || n,
|
|
266
|
+
locales: e.locales || [],
|
|
267
|
+
localeCodes: (e.locales || []).map((e) => e.code),
|
|
268
|
+
missingWarn: e.missingWarn ?? !0,
|
|
269
|
+
syncWithVitePress: e.syncWithVitePress !== !1,
|
|
270
|
+
translationDir: r,
|
|
271
|
+
disablePageLocales: i,
|
|
272
|
+
localeKeyToCode: e.localeKeyToCode ?? {},
|
|
273
|
+
base: t && t !== "/" ? t : void 0
|
|
274
|
+
}, s = process.cwd(), c = !!(e.messages || e.routeMessages), l = e.messages ?? {}, u = e.routeMessages ?? {}, f, p = () => !e.messages || !e.routeMessages, m = () => {
|
|
275
|
+
if (!p()) return;
|
|
276
|
+
let t = w({
|
|
277
|
+
rootDir: s,
|
|
278
|
+
translationDir: r,
|
|
279
|
+
disablePageLocales: i
|
|
280
|
+
});
|
|
281
|
+
e.messages || (l = t.root), e.routeMessages || (u = t.routes);
|
|
282
|
+
};
|
|
283
|
+
return {
|
|
284
|
+
name: "vite-plugin-i18n-vitepress",
|
|
285
|
+
configResolved(t) {
|
|
286
|
+
s = t.root, c = !!(e.messages || e.routeMessages), c && (e.messages && (l = e.messages), e.routeMessages && (u = e.routeMessages), p() && m(), e.messages && (l = e.messages), e.routeMessages && (u = e.routeMessages));
|
|
287
|
+
},
|
|
288
|
+
configureServer(e) {
|
|
289
|
+
if (c && !p()) return;
|
|
290
|
+
let t = d(s, r);
|
|
291
|
+
if (!a(t)) return;
|
|
292
|
+
e.watcher.add(t);
|
|
293
|
+
let n = () => {
|
|
294
|
+
f && clearTimeout(f), f = setTimeout(() => {
|
|
295
|
+
c && m();
|
|
296
|
+
let t = e.moduleGraph.getModuleById(O);
|
|
297
|
+
t && (e.moduleGraph.invalidateModule(t), e.ws.send({ type: "full-reload" }));
|
|
298
|
+
}, 50);
|
|
299
|
+
};
|
|
300
|
+
e.watcher.on("add", (e) => {
|
|
301
|
+
e.startsWith(t) && e.endsWith(".json") && n();
|
|
302
|
+
}), e.watcher.on("unlink", (e) => {
|
|
303
|
+
e.startsWith(t) && e.endsWith(".json") && n();
|
|
304
|
+
}), c && p() && e.watcher.on("change", (e) => {
|
|
305
|
+
e.startsWith(t) && e.endsWith(".json") && n();
|
|
306
|
+
});
|
|
307
|
+
},
|
|
308
|
+
resolveId(e) {
|
|
309
|
+
if (e === T) return E;
|
|
310
|
+
if (e === D) return O;
|
|
311
|
+
},
|
|
312
|
+
load(e) {
|
|
313
|
+
if (e === E) return `export const config = ${JSON.stringify(o)}`;
|
|
314
|
+
if (e === O) return c ? j(l, u) : A(s, r, i);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
311
317
|
}
|
|
312
|
-
function
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
);
|
|
322
|
-
}
|
|
318
|
+
function N(e, t) {
|
|
319
|
+
if (t.warnOnLocaleMismatch === !1) return;
|
|
320
|
+
let n = e.locales;
|
|
321
|
+
if (!n || !t.locales?.length) return;
|
|
322
|
+
let r = t.defaultLocale || t.locale, i = Object.keys(n), a = new Set(t.locales.map((e) => e.code));
|
|
323
|
+
for (let e of i) {
|
|
324
|
+
let n = e === "root" ? r : t.localeKeyToCode?.[e] ?? e;
|
|
325
|
+
a.has(n) || console.warn(`[i18n-micro/vitepress] VitePress locale key "${e}" maps to "${n}", which is not in i18n locales (${[...a].join(", ")}).`);
|
|
326
|
+
}
|
|
323
327
|
}
|
|
324
|
-
function
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
// the package during SSG so those IDs resolve (not left as bare Node imports).
|
|
382
|
-
ssr: {
|
|
383
|
-
...l,
|
|
384
|
-
noExternal: n === !0 ? !0 : i
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
};
|
|
328
|
+
function P(e, t) {
|
|
329
|
+
N(e, t);
|
|
330
|
+
let n = typeof e.base == "string" ? e.base : void 0, r = e.vite?.plugins, i = [...Array.isArray(r) ? r.flat() : [], M(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, f = t.meta ?? !!t.metaBaseUrl, p = t.locales || [], m = e.transformHead, h = e.transformPageData, g = f ? async (n) => {
|
|
331
|
+
let r = typeof m == "function" ? await m(n) : [], i = Array.isArray(r) ? r : [];
|
|
332
|
+
if (n.pageData?.frontmatter?.i18n?.disableMeta === !0) return i;
|
|
333
|
+
let a = n.pageData?.relativePath || "index.md", o = (typeof e.base == "string" ? e.base : void 0) ?? n.siteData?.base ?? n.siteConfig?.site?.base, s = x({
|
|
334
|
+
path: b(a),
|
|
335
|
+
locales: p,
|
|
336
|
+
defaultLocale: c,
|
|
337
|
+
localeKeyToCode: t.localeKeyToCode,
|
|
338
|
+
base: o,
|
|
339
|
+
metaBaseUrl: t.metaBaseUrl,
|
|
340
|
+
hreflangBaseLanguage: t.hreflangBaseLanguage,
|
|
341
|
+
canonicalQueryWhitelist: t.canonicalQueryWhitelist,
|
|
342
|
+
missingWarn: t.missingWarn
|
|
343
|
+
});
|
|
344
|
+
return [...i, ...s.head];
|
|
345
|
+
} : m, v = f ? async (n, r) => {
|
|
346
|
+
if (typeof h == "function" && await h(n, r), n.frontmatter?.i18n?.disableMeta === !0) return;
|
|
347
|
+
let i = x({
|
|
348
|
+
path: b(n.relativePath || "index.md"),
|
|
349
|
+
locales: p,
|
|
350
|
+
defaultLocale: c,
|
|
351
|
+
localeKeyToCode: t.localeKeyToCode,
|
|
352
|
+
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
|
+
addSeoAttributes: !1
|
|
358
|
+
});
|
|
359
|
+
i.htmlAttrs.lang && (n.frontmatter ??= {}, n.frontmatter.lang || (n.frontmatter.lang = i.htmlAttrs.lang));
|
|
360
|
+
} : h;
|
|
361
|
+
return {
|
|
362
|
+
...e,
|
|
363
|
+
...d ? { themeConfig: {
|
|
364
|
+
...u,
|
|
365
|
+
i18nRouting: _({
|
|
366
|
+
defaultLocale: c,
|
|
367
|
+
localeCodes: l,
|
|
368
|
+
localeKeyToCode: t.localeKeyToCode,
|
|
369
|
+
base: n
|
|
370
|
+
})
|
|
371
|
+
} } : {},
|
|
372
|
+
...f ? {
|
|
373
|
+
transformHead: g,
|
|
374
|
+
transformPageData: v
|
|
375
|
+
} : {},
|
|
376
|
+
vite: {
|
|
377
|
+
...e.vite,
|
|
378
|
+
plugins: i,
|
|
379
|
+
ssr: {
|
|
380
|
+
...a,
|
|
381
|
+
noExternal: o === !0 || s
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
};
|
|
388
385
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
fe as warnLocaleMismatch,
|
|
394
|
-
be as withI18n
|
|
395
|
-
};
|
|
396
|
-
//# sourceMappingURL=config.mjs.map
|
|
386
|
+
//#endregion
|
|
387
|
+
export { x as buildVitePressLocaleHead, n as buildVitePressLocales, b as relativePathToRoutePath, N as warnLocaleMismatch, P as withI18n };
|
|
388
|
+
|
|
389
|
+
//# sourceMappingURL=config.mjs.map
|