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