scribe-cms 0.0.13 → 0.0.14
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/README.md +1 -1
- package/dist/cli/index.cjs +20 -33
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +20 -33
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +20 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -33
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +20 -33
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +20 -33
- package/dist/runtime.js.map +1 -1
- package/dist/src/config/resolve-config.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -257,39 +257,7 @@ function resolveConfig(input, baseDir) {
|
|
|
257
257
|
if (localeRouting.strategy === "search-param" && !localeRouting.param) {
|
|
258
258
|
throw new Error('scribe config: localeRouting search-param requires a "param" name');
|
|
259
259
|
}
|
|
260
|
-
const localeFallbacks = {};
|
|
261
|
-
for (const [locale, chain] of Object.entries(raw.localeFallbacks ?? {})) {
|
|
262
|
-
if (!raw.locales.includes(locale)) {
|
|
263
|
-
throw new Error(
|
|
264
|
-
`scribe config: localeFallbacks key "${locale}" is not in locales [${raw.locales.join(", ")}]`
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
const seen = /* @__PURE__ */ new Set();
|
|
268
|
-
for (const fallback of chain) {
|
|
269
|
-
if (!raw.locales.includes(fallback)) {
|
|
270
|
-
throw new Error(
|
|
271
|
-
`scribe config: localeFallbacks["${locale}"] entry "${fallback}" is not in locales [${raw.locales.join(", ")}]`
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
if (fallback === locale) {
|
|
275
|
-
throw new Error(
|
|
276
|
-
`scribe config: localeFallbacks["${locale}"] must not contain its own key "${locale}"`
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
if (fallback === defaultLocale) {
|
|
280
|
-
throw new Error(
|
|
281
|
-
`scribe config: localeFallbacks["${locale}"] must not contain the defaultLocale "${defaultLocale}" \u2014 it is always the final fallback; remove it`
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
if (seen.has(fallback)) {
|
|
285
|
-
throw new Error(
|
|
286
|
-
`scribe config: localeFallbacks["${locale}"] contains duplicate entry "${fallback}"`
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
seen.add(fallback);
|
|
290
|
-
}
|
|
291
|
-
localeFallbacks[locale] = [...chain];
|
|
292
|
-
}
|
|
260
|
+
const localeFallbacks = raw.localeFallbacks === false ? {} : deriveLocaleFallbacks(raw.locales, defaultLocale);
|
|
293
261
|
const projectRoot = path3__default.default.resolve(baseDir ?? process.cwd(), raw.rootDir);
|
|
294
262
|
const contentRoot = path3__default.default.resolve(projectRoot, raw.contentDir ?? "content");
|
|
295
263
|
const storePath = path3__default.default.resolve(projectRoot, raw.store ?? ".scribe/store.sqlite");
|
|
@@ -329,6 +297,25 @@ function resolveConfig(input, baseDir) {
|
|
|
329
297
|
});
|
|
330
298
|
return config;
|
|
331
299
|
}
|
|
300
|
+
function deriveLocaleFallbacks(locales, defaultLocale) {
|
|
301
|
+
const byLowercase = new Map(locales.map((l) => [l.toLowerCase(), l]));
|
|
302
|
+
const fallbacks = {};
|
|
303
|
+
for (const locale of locales) {
|
|
304
|
+
const subtags = locale.split("-");
|
|
305
|
+
if (subtags.length < 2) continue;
|
|
306
|
+
const chain = [];
|
|
307
|
+
for (let end = subtags.length - 1; end >= 1; end--) {
|
|
308
|
+
const prefix = byLowercase.get(subtags.slice(0, end).join("-").toLowerCase());
|
|
309
|
+
if (prefix && prefix !== locale && prefix !== defaultLocale) {
|
|
310
|
+
chain.push(prefix);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (chain.length > 0) {
|
|
314
|
+
fallbacks[locale] = chain;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return fallbacks;
|
|
318
|
+
}
|
|
332
319
|
|
|
333
320
|
// src/core/introspect-schema.ts
|
|
334
321
|
function getArrayElement(schema) {
|