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/README.md
CHANGED
|
@@ -40,7 +40,7 @@ export default defineConfig({
|
|
|
40
40
|
// store: ".scribe/store.sqlite" (default)
|
|
41
41
|
locales: ["en", "fr"],
|
|
42
42
|
// defaultLocale: "en" (default)
|
|
43
|
-
// localeFallbacks:
|
|
43
|
+
// localeFallbacks: true (default: regional variants fall back to their base language, e.g. pt-BR to pt; set false to disable)
|
|
44
44
|
types: [
|
|
45
45
|
defineContentType({
|
|
46
46
|
id: "blog",
|
package/dist/cli/index.cjs
CHANGED
|
@@ -360,39 +360,7 @@ function resolveConfig(input, baseDir) {
|
|
|
360
360
|
if (localeRouting.strategy === "search-param" && !localeRouting.param) {
|
|
361
361
|
throw new Error('scribe config: localeRouting search-param requires a "param" name');
|
|
362
362
|
}
|
|
363
|
-
const localeFallbacks = {};
|
|
364
|
-
for (const [locale, chain] of Object.entries(raw.localeFallbacks ?? {})) {
|
|
365
|
-
if (!raw.locales.includes(locale)) {
|
|
366
|
-
throw new Error(
|
|
367
|
-
`scribe config: localeFallbacks key "${locale}" is not in locales [${raw.locales.join(", ")}]`
|
|
368
|
-
);
|
|
369
|
-
}
|
|
370
|
-
const seen = /* @__PURE__ */ new Set();
|
|
371
|
-
for (const fallback of chain) {
|
|
372
|
-
if (!raw.locales.includes(fallback)) {
|
|
373
|
-
throw new Error(
|
|
374
|
-
`scribe config: localeFallbacks["${locale}"] entry "${fallback}" is not in locales [${raw.locales.join(", ")}]`
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
if (fallback === locale) {
|
|
378
|
-
throw new Error(
|
|
379
|
-
`scribe config: localeFallbacks["${locale}"] must not contain its own key "${locale}"`
|
|
380
|
-
);
|
|
381
|
-
}
|
|
382
|
-
if (fallback === defaultLocale) {
|
|
383
|
-
throw new Error(
|
|
384
|
-
`scribe config: localeFallbacks["${locale}"] must not contain the defaultLocale "${defaultLocale}" \u2014 it is always the final fallback; remove it`
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
if (seen.has(fallback)) {
|
|
388
|
-
throw new Error(
|
|
389
|
-
`scribe config: localeFallbacks["${locale}"] contains duplicate entry "${fallback}"`
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
seen.add(fallback);
|
|
393
|
-
}
|
|
394
|
-
localeFallbacks[locale] = [...chain];
|
|
395
|
-
}
|
|
363
|
+
const localeFallbacks = raw.localeFallbacks === false ? {} : deriveLocaleFallbacks(raw.locales, defaultLocale);
|
|
396
364
|
const projectRoot = path3__default.default.resolve(baseDir ?? process.cwd(), raw.rootDir);
|
|
397
365
|
const contentRoot = path3__default.default.resolve(projectRoot, raw.contentDir ?? "content");
|
|
398
366
|
const storePath = path3__default.default.resolve(projectRoot, raw.store ?? ".scribe/store.sqlite");
|
|
@@ -432,6 +400,25 @@ function resolveConfig(input, baseDir) {
|
|
|
432
400
|
});
|
|
433
401
|
return config;
|
|
434
402
|
}
|
|
403
|
+
function deriveLocaleFallbacks(locales, defaultLocale) {
|
|
404
|
+
const byLowercase = new Map(locales.map((l) => [l.toLowerCase(), l]));
|
|
405
|
+
const fallbacks = {};
|
|
406
|
+
for (const locale of locales) {
|
|
407
|
+
const subtags = locale.split("-");
|
|
408
|
+
if (subtags.length < 2) continue;
|
|
409
|
+
const chain = [];
|
|
410
|
+
for (let end = subtags.length - 1; end >= 1; end--) {
|
|
411
|
+
const prefix = byLowercase.get(subtags.slice(0, end).join("-").toLowerCase());
|
|
412
|
+
if (prefix && prefix !== locale && prefix !== defaultLocale) {
|
|
413
|
+
chain.push(prefix);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (chain.length > 0) {
|
|
417
|
+
fallbacks[locale] = chain;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return fallbacks;
|
|
421
|
+
}
|
|
435
422
|
|
|
436
423
|
// src/create-project.ts
|
|
437
424
|
init_cjs_shims();
|