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/runtime.cjs
CHANGED
|
@@ -138,39 +138,7 @@ function resolveConfig(input, baseDir) {
|
|
|
138
138
|
if (localeRouting.strategy === "search-param" && !localeRouting.param) {
|
|
139
139
|
throw new Error('scribe config: localeRouting search-param requires a "param" name');
|
|
140
140
|
}
|
|
141
|
-
const localeFallbacks = {};
|
|
142
|
-
for (const [locale, chain] of Object.entries(raw.localeFallbacks ?? {})) {
|
|
143
|
-
if (!raw.locales.includes(locale)) {
|
|
144
|
-
throw new Error(
|
|
145
|
-
`scribe config: localeFallbacks key "${locale}" is not in locales [${raw.locales.join(", ")}]`
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
const seen = /* @__PURE__ */ new Set();
|
|
149
|
-
for (const fallback of chain) {
|
|
150
|
-
if (!raw.locales.includes(fallback)) {
|
|
151
|
-
throw new Error(
|
|
152
|
-
`scribe config: localeFallbacks["${locale}"] entry "${fallback}" is not in locales [${raw.locales.join(", ")}]`
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
if (fallback === locale) {
|
|
156
|
-
throw new Error(
|
|
157
|
-
`scribe config: localeFallbacks["${locale}"] must not contain its own key "${locale}"`
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
if (fallback === defaultLocale) {
|
|
161
|
-
throw new Error(
|
|
162
|
-
`scribe config: localeFallbacks["${locale}"] must not contain the defaultLocale "${defaultLocale}" \u2014 it is always the final fallback; remove it`
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
if (seen.has(fallback)) {
|
|
166
|
-
throw new Error(
|
|
167
|
-
`scribe config: localeFallbacks["${locale}"] contains duplicate entry "${fallback}"`
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
seen.add(fallback);
|
|
171
|
-
}
|
|
172
|
-
localeFallbacks[locale] = [...chain];
|
|
173
|
-
}
|
|
141
|
+
const localeFallbacks = raw.localeFallbacks === false ? {} : deriveLocaleFallbacks(raw.locales, defaultLocale);
|
|
174
142
|
const projectRoot = path__default.default.resolve(process.cwd(), raw.rootDir);
|
|
175
143
|
const contentRoot = path__default.default.resolve(projectRoot, raw.contentDir ?? "content");
|
|
176
144
|
const storePath = path__default.default.resolve(projectRoot, raw.store ?? ".scribe/store.sqlite");
|
|
@@ -210,6 +178,25 @@ function resolveConfig(input, baseDir) {
|
|
|
210
178
|
});
|
|
211
179
|
return config;
|
|
212
180
|
}
|
|
181
|
+
function deriveLocaleFallbacks(locales, defaultLocale) {
|
|
182
|
+
const byLowercase = new Map(locales.map((l) => [l.toLowerCase(), l]));
|
|
183
|
+
const fallbacks = {};
|
|
184
|
+
for (const locale of locales) {
|
|
185
|
+
const subtags = locale.split("-");
|
|
186
|
+
if (subtags.length < 2) continue;
|
|
187
|
+
const chain = [];
|
|
188
|
+
for (let end = subtags.length - 1; end >= 1; end--) {
|
|
189
|
+
const prefix = byLowercase.get(subtags.slice(0, end).join("-").toLowerCase());
|
|
190
|
+
if (prefix && prefix !== locale && prefix !== defaultLocale) {
|
|
191
|
+
chain.push(prefix);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (chain.length > 0) {
|
|
195
|
+
fallbacks[locale] = chain;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return fallbacks;
|
|
199
|
+
}
|
|
213
200
|
var FIELD_KIND = /* @__PURE__ */ Symbol.for("@genlook/scribe/fieldKind");
|
|
214
201
|
var RELATION_META = /* @__PURE__ */ Symbol.for("@genlook/scribe/relationMeta");
|
|
215
202
|
function getFieldKind(schema) {
|