scribe-cms 0.0.20 → 0.0.21
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/dist/cli/index.cjs +17 -9
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +17 -9
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +22 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -10
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +21 -9
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +21 -9
- package/dist/runtime.js.map +1 -1
- package/dist/src/create-project.d.ts +8 -2
- package/dist/src/create-project.d.ts.map +1 -1
- package/dist/src/create-scribe.d.ts.map +1 -1
- package/dist/src/inline/resolve-tokens.d.ts +9 -1
- package/dist/src/inline/resolve-tokens.d.ts.map +1 -1
- package/dist/src/inline/tokens.d.ts +2 -2
- package/dist/src/inline/tokens.d.ts.map +1 -1
- package/dist/studio/server.cjs +17 -9
- package/dist/studio/server.cjs.map +1 -1
- package/dist/studio/server.js +17 -9
- package/dist/studio/server.js.map +1 -1
- package/package.json +1 -1
package/dist/studio/server.js
CHANGED
|
@@ -288,18 +288,18 @@ function parseTokenInner(inner) {
|
|
|
288
288
|
}
|
|
289
289
|
case "relation": {
|
|
290
290
|
const parts = rest.split(":");
|
|
291
|
-
if (parts.length
|
|
291
|
+
if (parts.length !== 3) {
|
|
292
292
|
return {
|
|
293
293
|
ok: false,
|
|
294
|
-
reason: `relation must be relation:<typeId>:<enSlug
|
|
294
|
+
reason: `relation must be relation:<typeId>:<enSlug>:href or relation:<typeId>:<enSlug>:slug`
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
297
|
const [targetTypeId, enSlug, mode] = parts;
|
|
298
298
|
if (!targetTypeId || !enSlug) {
|
|
299
299
|
return { ok: false, reason: `relation is missing a typeId or enSlug` };
|
|
300
300
|
}
|
|
301
|
-
if (mode !==
|
|
302
|
-
return { ok: false, reason: `relation mode must be "slug" (got "${mode}")` };
|
|
301
|
+
if (mode !== "href" && mode !== "slug") {
|
|
302
|
+
return { ok: false, reason: `relation mode must be "href" or "slug" (got "${mode}")` };
|
|
303
303
|
}
|
|
304
304
|
return {
|
|
305
305
|
ok: true,
|
|
@@ -307,7 +307,7 @@ function parseTokenInner(inner) {
|
|
|
307
307
|
kind: "relation",
|
|
308
308
|
targetTypeId,
|
|
309
309
|
enSlug,
|
|
310
|
-
mode
|
|
310
|
+
mode
|
|
311
311
|
}
|
|
312
312
|
};
|
|
313
313
|
}
|
|
@@ -982,7 +982,9 @@ function isStringRecord(value) {
|
|
|
982
982
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
983
983
|
return Object.values(value).every((v) => typeof v === "string");
|
|
984
984
|
}
|
|
985
|
-
function createInlineResolver(config) {
|
|
985
|
+
function createInlineResolver(config, options = {}) {
|
|
986
|
+
const linkStyle = options.linkStyle ?? "app";
|
|
987
|
+
const exportExtension = options.exportExtension ?? ".md";
|
|
986
988
|
const urlBuilder = createUrlBuilder(config);
|
|
987
989
|
const typeById = new Map(config.types.map((t) => [t.id, t]));
|
|
988
990
|
const storePath = resolveStorePath(config);
|
|
@@ -1043,7 +1045,10 @@ function createInlineResolver(config) {
|
|
|
1043
1045
|
if (token.mode === "slug") return token.enSlug;
|
|
1044
1046
|
if (!isRoutableType(type)) return "";
|
|
1045
1047
|
const slug = localizedSlug(token.targetTypeId, token.enSlug, locale);
|
|
1046
|
-
|
|
1048
|
+
if (linkStyle === "export") {
|
|
1049
|
+
return urlBuilder.resolvePath(type.path, `${slug}${exportExtension}`, locale);
|
|
1050
|
+
}
|
|
1051
|
+
return type.path.replace("{slug}", slug);
|
|
1047
1052
|
}
|
|
1048
1053
|
}
|
|
1049
1054
|
}
|
|
@@ -1643,7 +1648,10 @@ function createProject(config, options = {}) {
|
|
|
1643
1648
|
}
|
|
1644
1649
|
return runtime;
|
|
1645
1650
|
};
|
|
1646
|
-
const inlineResolver = options.resolveInlineTokens ? createInlineResolver(config
|
|
1651
|
+
const inlineResolver = options.resolveInlineTokens ? createInlineResolver(config, {
|
|
1652
|
+
linkStyle: options.inlineLinkStyle,
|
|
1653
|
+
exportExtension: options.exportLinkExtension
|
|
1654
|
+
}) : void 0;
|
|
1647
1655
|
for (const type of config.types) {
|
|
1648
1656
|
runtimes.set(
|
|
1649
1657
|
type.id,
|
|
@@ -2294,7 +2302,7 @@ function validateInlineTokens(config) {
|
|
|
2294
2302
|
});
|
|
2295
2303
|
break;
|
|
2296
2304
|
}
|
|
2297
|
-
if (token.mode === "
|
|
2305
|
+
if (token.mode === "href") {
|
|
2298
2306
|
const targetType = typeById.get(token.targetTypeId);
|
|
2299
2307
|
if (!isRoutableType(targetType)) {
|
|
2300
2308
|
issues.push({
|