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.js CHANGED
@@ -1152,18 +1152,18 @@ function parseTokenInner(inner) {
1152
1152
  }
1153
1153
  case "relation": {
1154
1154
  const parts = rest.split(":");
1155
- if (parts.length < 2 || parts.length > 3) {
1155
+ if (parts.length !== 3) {
1156
1156
  return {
1157
1157
  ok: false,
1158
- reason: `relation must be relation:<typeId>:<enSlug> or relation:<typeId>:<enSlug>:slug`
1158
+ reason: `relation must be relation:<typeId>:<enSlug>:href or relation:<typeId>:<enSlug>:slug`
1159
1159
  };
1160
1160
  }
1161
1161
  const [targetTypeId, enSlug, mode] = parts;
1162
1162
  if (!targetTypeId || !enSlug) {
1163
1163
  return { ok: false, reason: `relation is missing a typeId or enSlug` };
1164
1164
  }
1165
- if (mode !== void 0 && mode !== "slug") {
1166
- return { ok: false, reason: `relation mode must be "slug" (got "${mode}")` };
1165
+ if (mode !== "href" && mode !== "slug") {
1166
+ return { ok: false, reason: `relation mode must be "href" or "slug" (got "${mode}")` };
1167
1167
  }
1168
1168
  return {
1169
1169
  ok: true,
@@ -1171,7 +1171,7 @@ function parseTokenInner(inner) {
1171
1171
  kind: "relation",
1172
1172
  targetTypeId,
1173
1173
  enSlug,
1174
- mode: mode === "slug" ? "slug" : "url"
1174
+ mode
1175
1175
  }
1176
1176
  };
1177
1177
  }
@@ -1277,7 +1277,9 @@ function isStringRecord(value) {
1277
1277
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
1278
1278
  return Object.values(value).every((v) => typeof v === "string");
1279
1279
  }
1280
- function createInlineResolver(config) {
1280
+ function createInlineResolver(config, options = {}) {
1281
+ const linkStyle = options.linkStyle ?? "app";
1282
+ const exportExtension = options.exportExtension ?? ".md";
1281
1283
  const urlBuilder = createUrlBuilder(config);
1282
1284
  const typeById = new Map(config.types.map((t) => [t.id, t]));
1283
1285
  const storePath = resolveStorePath(config);
@@ -1338,7 +1340,10 @@ function createInlineResolver(config) {
1338
1340
  if (token.mode === "slug") return token.enSlug;
1339
1341
  if (!isRoutableType(type)) return "";
1340
1342
  const slug = localizedSlug(token.targetTypeId, token.enSlug, locale);
1341
- return urlBuilder.resolvePath(type.path, slug, locale);
1343
+ if (linkStyle === "export") {
1344
+ return urlBuilder.resolvePath(type.path, `${slug}${exportExtension}`, locale);
1345
+ }
1346
+ return type.path.replace("{slug}", slug);
1342
1347
  }
1343
1348
  }
1344
1349
  }
@@ -1879,7 +1884,10 @@ function createProject(config, options = {}) {
1879
1884
  }
1880
1885
  return runtime;
1881
1886
  };
1882
- const inlineResolver = options.resolveInlineTokens ? createInlineResolver(config) : void 0;
1887
+ const inlineResolver = options.resolveInlineTokens ? createInlineResolver(config, {
1888
+ linkStyle: options.inlineLinkStyle,
1889
+ exportExtension: options.exportLinkExtension
1890
+ }) : void 0;
1883
1891
  for (const type of config.types) {
1884
1892
  runtimes.set(
1885
1893
  type.id,
@@ -2635,7 +2643,7 @@ function validateInlineTokens(config) {
2635
2643
  });
2636
2644
  break;
2637
2645
  }
2638
- if (token.mode === "url") {
2646
+ if (token.mode === "href") {
2639
2647
  const targetType = typeById.get(token.targetTypeId);
2640
2648
  if (!isRoutableType(targetType)) {
2641
2649
  issues.push({