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.cjs
CHANGED
|
@@ -895,18 +895,18 @@ function parseTokenInner(inner) {
|
|
|
895
895
|
}
|
|
896
896
|
case "relation": {
|
|
897
897
|
const parts = rest.split(":");
|
|
898
|
-
if (parts.length
|
|
898
|
+
if (parts.length !== 3) {
|
|
899
899
|
return {
|
|
900
900
|
ok: false,
|
|
901
|
-
reason: `relation must be relation:<typeId>:<enSlug
|
|
901
|
+
reason: `relation must be relation:<typeId>:<enSlug>:href or relation:<typeId>:<enSlug>:slug`
|
|
902
902
|
};
|
|
903
903
|
}
|
|
904
904
|
const [targetTypeId, enSlug, mode] = parts;
|
|
905
905
|
if (!targetTypeId || !enSlug) {
|
|
906
906
|
return { ok: false, reason: `relation is missing a typeId or enSlug` };
|
|
907
907
|
}
|
|
908
|
-
if (mode !==
|
|
909
|
-
return { ok: false, reason: `relation mode must be "slug" (got "${mode}")` };
|
|
908
|
+
if (mode !== "href" && mode !== "slug") {
|
|
909
|
+
return { ok: false, reason: `relation mode must be "href" or "slug" (got "${mode}")` };
|
|
910
910
|
}
|
|
911
911
|
return {
|
|
912
912
|
ok: true,
|
|
@@ -914,7 +914,7 @@ function parseTokenInner(inner) {
|
|
|
914
914
|
kind: "relation",
|
|
915
915
|
targetTypeId,
|
|
916
916
|
enSlug,
|
|
917
|
-
mode
|
|
917
|
+
mode
|
|
918
918
|
}
|
|
919
919
|
};
|
|
920
920
|
}
|
|
@@ -987,7 +987,9 @@ function isStringRecord(value) {
|
|
|
987
987
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
988
988
|
return Object.values(value).every((v) => typeof v === "string");
|
|
989
989
|
}
|
|
990
|
-
function createInlineResolver(config) {
|
|
990
|
+
function createInlineResolver(config, options = {}) {
|
|
991
|
+
const linkStyle = options.linkStyle ?? "app";
|
|
992
|
+
const exportExtension = options.exportExtension ?? ".md";
|
|
991
993
|
const urlBuilder = createUrlBuilder(config);
|
|
992
994
|
const typeById = new Map(config.types.map((t) => [t.id, t]));
|
|
993
995
|
const storePath = resolveStorePath(config);
|
|
@@ -1048,7 +1050,10 @@ function createInlineResolver(config) {
|
|
|
1048
1050
|
if (token.mode === "slug") return token.enSlug;
|
|
1049
1051
|
if (!isRoutableType(type)) return "";
|
|
1050
1052
|
const slug = localizedSlug(token.targetTypeId, token.enSlug, locale);
|
|
1051
|
-
|
|
1053
|
+
if (linkStyle === "export") {
|
|
1054
|
+
return urlBuilder.resolvePath(type.path, `${slug}${exportExtension}`, locale);
|
|
1055
|
+
}
|
|
1056
|
+
return type.path.replace("{slug}", slug);
|
|
1052
1057
|
}
|
|
1053
1058
|
}
|
|
1054
1059
|
}
|
|
@@ -1562,7 +1567,10 @@ function createProject(config, options = {}) {
|
|
|
1562
1567
|
}
|
|
1563
1568
|
return runtime;
|
|
1564
1569
|
};
|
|
1565
|
-
const inlineResolver = options.resolveInlineTokens ? createInlineResolver(config
|
|
1570
|
+
const inlineResolver = options.resolveInlineTokens ? createInlineResolver(config, {
|
|
1571
|
+
linkStyle: options.inlineLinkStyle,
|
|
1572
|
+
exportExtension: options.exportLinkExtension
|
|
1573
|
+
}) : void 0;
|
|
1566
1574
|
for (const type of config.types) {
|
|
1567
1575
|
runtimes.set(
|
|
1568
1576
|
type.id,
|
|
@@ -1822,7 +1830,11 @@ async function generateSitemap(project, options) {
|
|
|
1822
1830
|
// src/create-scribe.ts
|
|
1823
1831
|
function createScribe(input) {
|
|
1824
1832
|
const config = resolveConfig(input);
|
|
1825
|
-
const project = createProject(config, {
|
|
1833
|
+
const project = createProject(config, {
|
|
1834
|
+
resolveAssets: true,
|
|
1835
|
+
resolveInlineTokens: true,
|
|
1836
|
+
inlineLinkStyle: "app"
|
|
1837
|
+
});
|
|
1826
1838
|
const scribe = {
|
|
1827
1839
|
config,
|
|
1828
1840
|
project,
|