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/index.js CHANGED
@@ -1148,18 +1148,18 @@ function parseTokenInner(inner) {
1148
1148
  }
1149
1149
  case "relation": {
1150
1150
  const parts = rest.split(":");
1151
- if (parts.length < 2 || parts.length > 3) {
1151
+ if (parts.length !== 3) {
1152
1152
  return {
1153
1153
  ok: false,
1154
- reason: `relation must be relation:<typeId>:<enSlug> or relation:<typeId>:<enSlug>:slug`
1154
+ reason: `relation must be relation:<typeId>:<enSlug>:href or relation:<typeId>:<enSlug>:slug`
1155
1155
  };
1156
1156
  }
1157
1157
  const [targetTypeId, enSlug, mode] = parts;
1158
1158
  if (!targetTypeId || !enSlug) {
1159
1159
  return { ok: false, reason: `relation is missing a typeId or enSlug` };
1160
1160
  }
1161
- if (mode !== void 0 && mode !== "slug") {
1162
- return { ok: false, reason: `relation mode must be "slug" (got "${mode}")` };
1161
+ if (mode !== "href" && mode !== "slug") {
1162
+ return { ok: false, reason: `relation mode must be "href" or "slug" (got "${mode}")` };
1163
1163
  }
1164
1164
  return {
1165
1165
  ok: true,
@@ -1167,7 +1167,7 @@ function parseTokenInner(inner) {
1167
1167
  kind: "relation",
1168
1168
  targetTypeId,
1169
1169
  enSlug,
1170
- mode: mode === "slug" ? "slug" : "url"
1170
+ mode
1171
1171
  }
1172
1172
  };
1173
1173
  }
@@ -1273,7 +1273,9 @@ function isStringRecord(value) {
1273
1273
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
1274
1274
  return Object.values(value).every((v) => typeof v === "string");
1275
1275
  }
1276
- function createInlineResolver(config) {
1276
+ function createInlineResolver(config, options = {}) {
1277
+ const linkStyle = options.linkStyle ?? "app";
1278
+ const exportExtension = options.exportExtension ?? ".md";
1277
1279
  const urlBuilder = createUrlBuilder(config);
1278
1280
  const typeById = new Map(config.types.map((t) => [t.id, t]));
1279
1281
  const storePath = resolveStorePath(config);
@@ -1334,7 +1336,10 @@ function createInlineResolver(config) {
1334
1336
  if (token.mode === "slug") return token.enSlug;
1335
1337
  if (!isRoutableType(type)) return "";
1336
1338
  const slug = localizedSlug2(token.targetTypeId, token.enSlug, locale);
1337
- return urlBuilder.resolvePath(type.path, slug, locale);
1339
+ if (linkStyle === "export") {
1340
+ return urlBuilder.resolvePath(type.path, `${slug}${exportExtension}`, locale);
1341
+ }
1342
+ return type.path.replace("{slug}", slug);
1338
1343
  }
1339
1344
  }
1340
1345
  }
@@ -1873,7 +1878,10 @@ function createProject(config, options = {}) {
1873
1878
  }
1874
1879
  return runtime;
1875
1880
  };
1876
- const inlineResolver = options.resolveInlineTokens ? createInlineResolver(config) : void 0;
1881
+ const inlineResolver = options.resolveInlineTokens ? createInlineResolver(config, {
1882
+ linkStyle: options.inlineLinkStyle,
1883
+ exportExtension: options.exportLinkExtension
1884
+ }) : void 0;
1877
1885
  for (const type of config.types) {
1878
1886
  runtimes.set(
1879
1887
  type.id,
@@ -2396,7 +2404,11 @@ async function generateSitemap(project, options) {
2396
2404
  // src/create-scribe.ts
2397
2405
  function createScribe(input) {
2398
2406
  const config = resolveConfig(input);
2399
- const project = createProject(config, { resolveAssets: true, resolveInlineTokens: true });
2407
+ const project = createProject(config, {
2408
+ resolveAssets: true,
2409
+ resolveInlineTokens: true,
2410
+ inlineLinkStyle: "app"
2411
+ });
2400
2412
  const scribe = {
2401
2413
  config,
2402
2414
  project,
@@ -2987,7 +2999,7 @@ function validateInlineTokens(config) {
2987
2999
  });
2988
3000
  break;
2989
3001
  }
2990
- if (token.mode === "url") {
3002
+ if (token.mode === "href") {
2991
3003
  const targetType = typeById.get(token.targetTypeId);
2992
3004
  if (!isRoutableType(targetType)) {
2993
3005
  issues.push({