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/runtime.js
CHANGED
|
@@ -884,18 +884,18 @@ function parseTokenInner(inner) {
|
|
|
884
884
|
}
|
|
885
885
|
case "relation": {
|
|
886
886
|
const parts = rest.split(":");
|
|
887
|
-
if (parts.length
|
|
887
|
+
if (parts.length !== 3) {
|
|
888
888
|
return {
|
|
889
889
|
ok: false,
|
|
890
|
-
reason: `relation must be relation:<typeId>:<enSlug
|
|
890
|
+
reason: `relation must be relation:<typeId>:<enSlug>:href or relation:<typeId>:<enSlug>:slug`
|
|
891
891
|
};
|
|
892
892
|
}
|
|
893
893
|
const [targetTypeId, enSlug, mode] = parts;
|
|
894
894
|
if (!targetTypeId || !enSlug) {
|
|
895
895
|
return { ok: false, reason: `relation is missing a typeId or enSlug` };
|
|
896
896
|
}
|
|
897
|
-
if (mode !==
|
|
898
|
-
return { ok: false, reason: `relation mode must be "slug" (got "${mode}")` };
|
|
897
|
+
if (mode !== "href" && mode !== "slug") {
|
|
898
|
+
return { ok: false, reason: `relation mode must be "href" or "slug" (got "${mode}")` };
|
|
899
899
|
}
|
|
900
900
|
return {
|
|
901
901
|
ok: true,
|
|
@@ -903,7 +903,7 @@ function parseTokenInner(inner) {
|
|
|
903
903
|
kind: "relation",
|
|
904
904
|
targetTypeId,
|
|
905
905
|
enSlug,
|
|
906
|
-
mode
|
|
906
|
+
mode
|
|
907
907
|
}
|
|
908
908
|
};
|
|
909
909
|
}
|
|
@@ -976,7 +976,9 @@ function isStringRecord(value) {
|
|
|
976
976
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
977
977
|
return Object.values(value).every((v) => typeof v === "string");
|
|
978
978
|
}
|
|
979
|
-
function createInlineResolver(config) {
|
|
979
|
+
function createInlineResolver(config, options = {}) {
|
|
980
|
+
const linkStyle = options.linkStyle ?? "app";
|
|
981
|
+
const exportExtension = options.exportExtension ?? ".md";
|
|
980
982
|
const urlBuilder = createUrlBuilder(config);
|
|
981
983
|
const typeById = new Map(config.types.map((t) => [t.id, t]));
|
|
982
984
|
const storePath = resolveStorePath(config);
|
|
@@ -1037,7 +1039,10 @@ function createInlineResolver(config) {
|
|
|
1037
1039
|
if (token.mode === "slug") return token.enSlug;
|
|
1038
1040
|
if (!isRoutableType(type)) return "";
|
|
1039
1041
|
const slug = localizedSlug(token.targetTypeId, token.enSlug, locale);
|
|
1040
|
-
|
|
1042
|
+
if (linkStyle === "export") {
|
|
1043
|
+
return urlBuilder.resolvePath(type.path, `${slug}${exportExtension}`, locale);
|
|
1044
|
+
}
|
|
1045
|
+
return type.path.replace("{slug}", slug);
|
|
1041
1046
|
}
|
|
1042
1047
|
}
|
|
1043
1048
|
}
|
|
@@ -1551,7 +1556,10 @@ function createProject(config, options = {}) {
|
|
|
1551
1556
|
}
|
|
1552
1557
|
return runtime;
|
|
1553
1558
|
};
|
|
1554
|
-
const inlineResolver = options.resolveInlineTokens ? createInlineResolver(config
|
|
1559
|
+
const inlineResolver = options.resolveInlineTokens ? createInlineResolver(config, {
|
|
1560
|
+
linkStyle: options.inlineLinkStyle,
|
|
1561
|
+
exportExtension: options.exportLinkExtension
|
|
1562
|
+
}) : void 0;
|
|
1555
1563
|
for (const type of config.types) {
|
|
1556
1564
|
runtimes.set(
|
|
1557
1565
|
type.id,
|
|
@@ -1811,7 +1819,11 @@ async function generateSitemap(project, options) {
|
|
|
1811
1819
|
// src/create-scribe.ts
|
|
1812
1820
|
function createScribe(input) {
|
|
1813
1821
|
const config = resolveConfig(input);
|
|
1814
|
-
const project = createProject(config, {
|
|
1822
|
+
const project = createProject(config, {
|
|
1823
|
+
resolveAssets: true,
|
|
1824
|
+
resolveInlineTokens: true,
|
|
1825
|
+
inlineLinkStyle: "app"
|
|
1826
|
+
});
|
|
1815
1827
|
const scribe = {
|
|
1816
1828
|
config,
|
|
1817
1829
|
project,
|