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/cli/index.js
CHANGED
|
@@ -343,39 +343,7 @@ function resolveConfig(input, baseDir) {
|
|
|
343
343
|
if (localeRouting.strategy === "search-param" && !localeRouting.param) {
|
|
344
344
|
throw new Error('scribe config: localeRouting search-param requires a "param" name');
|
|
345
345
|
}
|
|
346
|
-
const localeFallbacks = {};
|
|
347
|
-
for (const [locale, chain] of Object.entries(raw.localeFallbacks ?? {})) {
|
|
348
|
-
if (!raw.locales.includes(locale)) {
|
|
349
|
-
throw new Error(
|
|
350
|
-
`scribe config: localeFallbacks key "${locale}" is not in locales [${raw.locales.join(", ")}]`
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
const seen = /* @__PURE__ */ new Set();
|
|
354
|
-
for (const fallback of chain) {
|
|
355
|
-
if (!raw.locales.includes(fallback)) {
|
|
356
|
-
throw new Error(
|
|
357
|
-
`scribe config: localeFallbacks["${locale}"] entry "${fallback}" is not in locales [${raw.locales.join(", ")}]`
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
if (fallback === locale) {
|
|
361
|
-
throw new Error(
|
|
362
|
-
`scribe config: localeFallbacks["${locale}"] must not contain its own key "${locale}"`
|
|
363
|
-
);
|
|
364
|
-
}
|
|
365
|
-
if (fallback === defaultLocale) {
|
|
366
|
-
throw new Error(
|
|
367
|
-
`scribe config: localeFallbacks["${locale}"] must not contain the defaultLocale "${defaultLocale}" \u2014 it is always the final fallback; remove it`
|
|
368
|
-
);
|
|
369
|
-
}
|
|
370
|
-
if (seen.has(fallback)) {
|
|
371
|
-
throw new Error(
|
|
372
|
-
`scribe config: localeFallbacks["${locale}"] contains duplicate entry "${fallback}"`
|
|
373
|
-
);
|
|
374
|
-
}
|
|
375
|
-
seen.add(fallback);
|
|
376
|
-
}
|
|
377
|
-
localeFallbacks[locale] = [...chain];
|
|
378
|
-
}
|
|
346
|
+
const localeFallbacks = raw.localeFallbacks === false ? {} : deriveLocaleFallbacks(raw.locales, defaultLocale);
|
|
379
347
|
const projectRoot = path4.resolve(baseDir ?? process.cwd(), raw.rootDir);
|
|
380
348
|
const contentRoot = path4.resolve(projectRoot, raw.contentDir ?? "content");
|
|
381
349
|
const storePath = path4.resolve(projectRoot, raw.store ?? ".scribe/store.sqlite");
|
|
@@ -415,6 +383,25 @@ function resolveConfig(input, baseDir) {
|
|
|
415
383
|
});
|
|
416
384
|
return config;
|
|
417
385
|
}
|
|
386
|
+
function deriveLocaleFallbacks(locales, defaultLocale) {
|
|
387
|
+
const byLowercase = new Map(locales.map((l) => [l.toLowerCase(), l]));
|
|
388
|
+
const fallbacks = {};
|
|
389
|
+
for (const locale of locales) {
|
|
390
|
+
const subtags = locale.split("-");
|
|
391
|
+
if (subtags.length < 2) continue;
|
|
392
|
+
const chain = [];
|
|
393
|
+
for (let end = subtags.length - 1; end >= 1; end--) {
|
|
394
|
+
const prefix = byLowercase.get(subtags.slice(0, end).join("-").toLowerCase());
|
|
395
|
+
if (prefix && prefix !== locale && prefix !== defaultLocale) {
|
|
396
|
+
chain.push(prefix);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (chain.length > 0) {
|
|
400
|
+
fallbacks[locale] = chain;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return fallbacks;
|
|
404
|
+
}
|
|
418
405
|
|
|
419
406
|
// src/create-project.ts
|
|
420
407
|
init_esm_shims();
|