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/cli/index.cjs
CHANGED
|
@@ -1169,18 +1169,18 @@ function parseTokenInner(inner) {
|
|
|
1169
1169
|
}
|
|
1170
1170
|
case "relation": {
|
|
1171
1171
|
const parts = rest.split(":");
|
|
1172
|
-
if (parts.length
|
|
1172
|
+
if (parts.length !== 3) {
|
|
1173
1173
|
return {
|
|
1174
1174
|
ok: false,
|
|
1175
|
-
reason: `relation must be relation:<typeId>:<enSlug
|
|
1175
|
+
reason: `relation must be relation:<typeId>:<enSlug>:href or relation:<typeId>:<enSlug>:slug`
|
|
1176
1176
|
};
|
|
1177
1177
|
}
|
|
1178
1178
|
const [targetTypeId, enSlug, mode] = parts;
|
|
1179
1179
|
if (!targetTypeId || !enSlug) {
|
|
1180
1180
|
return { ok: false, reason: `relation is missing a typeId or enSlug` };
|
|
1181
1181
|
}
|
|
1182
|
-
if (mode !==
|
|
1183
|
-
return { ok: false, reason: `relation mode must be "slug" (got "${mode}")` };
|
|
1182
|
+
if (mode !== "href" && mode !== "slug") {
|
|
1183
|
+
return { ok: false, reason: `relation mode must be "href" or "slug" (got "${mode}")` };
|
|
1184
1184
|
}
|
|
1185
1185
|
return {
|
|
1186
1186
|
ok: true,
|
|
@@ -1188,7 +1188,7 @@ function parseTokenInner(inner) {
|
|
|
1188
1188
|
kind: "relation",
|
|
1189
1189
|
targetTypeId,
|
|
1190
1190
|
enSlug,
|
|
1191
|
-
mode
|
|
1191
|
+
mode
|
|
1192
1192
|
}
|
|
1193
1193
|
};
|
|
1194
1194
|
}
|
|
@@ -1294,7 +1294,9 @@ function isStringRecord(value) {
|
|
|
1294
1294
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
1295
1295
|
return Object.values(value).every((v) => typeof v === "string");
|
|
1296
1296
|
}
|
|
1297
|
-
function createInlineResolver(config) {
|
|
1297
|
+
function createInlineResolver(config, options = {}) {
|
|
1298
|
+
const linkStyle = options.linkStyle ?? "app";
|
|
1299
|
+
const exportExtension = options.exportExtension ?? ".md";
|
|
1298
1300
|
const urlBuilder = createUrlBuilder(config);
|
|
1299
1301
|
const typeById = new Map(config.types.map((t) => [t.id, t]));
|
|
1300
1302
|
const storePath = resolveStorePath(config);
|
|
@@ -1355,7 +1357,10 @@ function createInlineResolver(config) {
|
|
|
1355
1357
|
if (token.mode === "slug") return token.enSlug;
|
|
1356
1358
|
if (!isRoutableType(type)) return "";
|
|
1357
1359
|
const slug = localizedSlug(token.targetTypeId, token.enSlug, locale);
|
|
1358
|
-
|
|
1360
|
+
if (linkStyle === "export") {
|
|
1361
|
+
return urlBuilder.resolvePath(type.path, `${slug}${exportExtension}`, locale);
|
|
1362
|
+
}
|
|
1363
|
+
return type.path.replace("{slug}", slug);
|
|
1359
1364
|
}
|
|
1360
1365
|
}
|
|
1361
1366
|
}
|
|
@@ -1896,7 +1901,10 @@ function createProject(config, options = {}) {
|
|
|
1896
1901
|
}
|
|
1897
1902
|
return runtime;
|
|
1898
1903
|
};
|
|
1899
|
-
const inlineResolver = options.resolveInlineTokens ? createInlineResolver(config
|
|
1904
|
+
const inlineResolver = options.resolveInlineTokens ? createInlineResolver(config, {
|
|
1905
|
+
linkStyle: options.inlineLinkStyle,
|
|
1906
|
+
exportExtension: options.exportLinkExtension
|
|
1907
|
+
}) : void 0;
|
|
1900
1908
|
for (const type of config.types) {
|
|
1901
1909
|
runtimes.set(
|
|
1902
1910
|
type.id,
|
|
@@ -2652,7 +2660,7 @@ function validateInlineTokens(config) {
|
|
|
2652
2660
|
});
|
|
2653
2661
|
break;
|
|
2654
2662
|
}
|
|
2655
|
-
if (token.mode === "
|
|
2663
|
+
if (token.mode === "href") {
|
|
2656
2664
|
const targetType = typeById.get(token.targetTypeId);
|
|
2657
2665
|
if (!isRoutableType(targetType)) {
|
|
2658
2666
|
issues.push({
|