scribe-cms 0.0.20 → 0.0.22
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 +27 -14
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +27 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +32 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -15
- 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/src/translate/prompts/translation-prompt.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({
|
|
@@ -3640,10 +3652,10 @@ var LOCALE_NAMES = {
|
|
|
3640
3652
|
};
|
|
3641
3653
|
function defaultLocalizationPrompt(localeName, locale) {
|
|
3642
3654
|
return [
|
|
3643
|
-
`
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3655
|
+
`Write the content above in natural ${localeName} (${locale}), as if it had been originally authored by a native ${localeName} copywriter for that market.`,
|
|
3656
|
+
`Preserve the source tone and brand voice, but express every idea the way ${localeName} copy actually reads \u2014 never word-for-word.`,
|
|
3657
|
+
`Use native ${localeName} typographic conventions for quotation marks, apostrophes, and spacing around punctuation \u2014 not the source language's.`,
|
|
3658
|
+
`Before returning, re-read each ${localeName} sentence on its own: if it is ambiguous, unidiomatic, or reads like a translation, rewrite it.`
|
|
3647
3659
|
].join(" ");
|
|
3648
3660
|
}
|
|
3649
3661
|
function buildLocalizationPrompt(promptOverride, localeName, locale) {
|
|
@@ -3653,7 +3665,12 @@ function buildLocalizationPrompt(promptOverride, localeName, locale) {
|
|
|
3653
3665
|
|
|
3654
3666
|
${localeDirective}`;
|
|
3655
3667
|
}
|
|
3656
|
-
var TASK_FRAMING =
|
|
3668
|
+
var TASK_FRAMING = [
|
|
3669
|
+
"You are a native-speaker marketing copywriter producing the localized edition of the content below. The target language is specified at the end of this prompt.",
|
|
3670
|
+
"You are NOT translating a document. Each sentence in the source tells you the INTENT \u2014 what it must make the reader feel or understand. Write copy that accomplishes the same thing, the way a native copywriter would have written it from scratch.",
|
|
3671
|
+
"Never mirror the source sentence structure when the target language would naturally phrase the idea differently. Calqued syntax is the #1 failure mode.",
|
|
3672
|
+
"When the source uses wordplay, an idiom, or a punchy rhetorical device, recreate the effect rather than the words. If no natural equivalent exists, write a plain, confident line that carries the same message \u2014 never a literal rendering that sounds odd or ambiguous in the target language."
|
|
3673
|
+
].join("\n");
|
|
3657
3674
|
function buildOutputFormatLine(hasFrontmatter, slugStrategy) {
|
|
3658
3675
|
if (!hasFrontmatter) {
|
|
3659
3676
|
return slugStrategy === "localized" ? "`body` (string, full MDX body), `slug` (string)." : "`body` (string, full MDX body).";
|