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/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
|
|
1151
|
+
if (parts.length !== 3) {
|
|
1152
1152
|
return {
|
|
1153
1153
|
ok: false,
|
|
1154
|
-
reason: `relation must be relation:<typeId>:<enSlug
|
|
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 !==
|
|
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
|
|
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
|
-
|
|
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
|
|
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, {
|
|
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 === "
|
|
3002
|
+
if (token.mode === "href") {
|
|
2991
3003
|
const targetType = typeById.get(token.targetTypeId);
|
|
2992
3004
|
if (!isRoutableType(targetType)) {
|
|
2993
3005
|
issues.push({
|