@taprootio/site-authoring 0.42.0 → 0.56.0
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/README.md +110 -12
- package/examples/riverbend-wellness/settings/site-publishing-preferences.json +3 -0
- package/examples/riverbend-wellness/settings/taproot-styles.json +11 -0
- package/package.json +4 -3
- package/src/api.js +242 -23
- package/src/appearance-contract.js +264 -3
- package/src/authored-tag-names.js +88 -0
- package/src/authors-contract.js +71 -3
- package/src/block-flow.js +103 -1
- package/src/brand-color.js +22 -0
- package/src/breadcrumb-artwork.js +234 -0
- package/src/breadcrumb-separators.js +11 -0
- package/src/changelog.json +160 -0
- package/src/chrome-features.js +6 -2
- package/src/chrome-input.js +1 -0
- package/src/chrome-paint-catalog-taproot.json +3 -3
- package/src/chrome-report.js +91 -12
- package/src/cli.js +136 -38
- package/src/constants.js +1 -0
- package/src/content/components.js +27 -4
- package/src/content/external-link.js +2 -1
- package/src/content/markdown.js +271 -101
- package/src/content/tiptap-prosemirror.ts +125 -43
- package/src/content/validate-document.js +4 -1
- package/src/content-inset.js +48 -0
- package/src/errors.js +1 -0
- package/src/espalier-shared.js +26 -0
- package/src/field-suggestions.js +40 -0
- package/src/fixture-init.js +22 -5
- package/src/font-catalog.js +11 -1
- package/src/footer-brand-inputs.js +22 -3
- package/src/footer-content.js +1 -0
- package/src/footer-contract.js +11 -0
- package/src/footer-cta-styles.js +6 -0
- package/src/footer-draft-hash.js +4 -2
- package/src/footer-fit.js +62 -15
- package/src/footer-workspace.js +44 -7
- package/src/latest-posts-tags.js +57 -0
- package/src/page-metadata.js +15 -13
- package/src/page-structure-checks.js +5 -0
- package/src/page-tag-badge-modes.js +6 -0
- package/src/page-tag-writes.js +158 -0
- package/src/page-type-tags.js +16 -0
- package/src/presentation-reference.js +297 -86
- package/src/recipe-page-options.js +22 -0
- package/src/recipe-step-contract.js +164 -0
- package/src/recipe-step-contract.json +65 -0
- package/src/reference-help.js +182 -79
- package/src/session.js +39 -24
- package/src/setting-reference.js +239 -48
- package/src/settings-catalog.js +63 -0
- package/src/site-check-findings.js +23 -5
- package/src/site-check-rules.json +1 -0
- package/src/site-health-findings.js +13 -13
- package/src/styling-fixed-values.js +71 -0
- package/src/tag-destination-warnings.js +35 -0
- package/src/template-token-reach.json +242 -0
- package/src/theme-proposals.js +18 -27
- package/src/theme-resolve.js +265 -23
- package/src/theme-validation.js +118 -7
- package/src/token-reach.js +222 -0
- package/src/typed-page-reference.js +94 -16
- package/src/typed-pages.js +233 -74
- package/src/verbs/authors.js +198 -33
- package/src/verbs/deploy.js +6 -0
- package/src/verbs/footer-push.js +30 -5
- package/src/verbs/forms-push.js +11 -3
- package/src/verbs/index.js +4 -2
- package/src/verbs/pages-delete.js +19 -10
- package/src/verbs/pages-push.js +225 -71
- package/src/verbs/plan.js +10 -4
- package/src/verbs/pull.js +324 -69
- package/src/verbs/staging-review.js +27 -1
- package/src/verbs/status.js +22 -0
- package/src/verbs/theme-push.js +93 -25
- package/src/verbs/theme-resolve.js +189 -55
- package/src/verbs/validate.js +6 -5
- package/src/workspace-check.js +35 -3
- package/src/workspace.js +73 -2
- package/test/fixtures/default-site-theme.json +516 -0
package/src/footer-contract.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
normalizeFooterResponsiveAlignment,
|
|
15
15
|
normalizeFooterResponsiveInlineAlignment,
|
|
16
16
|
} from "./footer-alignment.js";
|
|
17
|
+
import { DEFAULT_FOOTER_CTA_STYLE, FOOTER_CTA_STYLES, resolveFooterCtaStyle } from "./footer-cta-styles.js";
|
|
17
18
|
import { isSocialLinkUrl, SOCIAL_LINK_URL_MAX_LENGTH, trimSocialLinkInput } from "./social-link-url.js";
|
|
18
19
|
import socialPlatforms from "./social-platforms.json" with { type: "json" };
|
|
19
20
|
|
|
@@ -83,6 +84,7 @@ export const FOOTER_FIELD_INVENTORY = Object.freeze({
|
|
|
83
84
|
"logoBox",
|
|
84
85
|
"context",
|
|
85
86
|
"logoVariant",
|
|
87
|
+
"asideCtaStyle",
|
|
86
88
|
]),
|
|
87
89
|
FooterLinkColumn: Object.freeze(["id", "groups", "span", "alignment"]),
|
|
88
90
|
FooterAlignment: Object.freeze(["horizontal", "vertical", "textAlign"]),
|
|
@@ -561,6 +563,7 @@ export function footerDefaults() {
|
|
|
561
563
|
logoBox: "fixed",
|
|
562
564
|
asideSpan: 1,
|
|
563
565
|
asideCta: undefined,
|
|
566
|
+
asideCtaStyle: DEFAULT_FOOTER_CTA_STYLE,
|
|
564
567
|
bottomLinks: [],
|
|
565
568
|
light: defaults(),
|
|
566
569
|
dark: defaults(),
|
|
@@ -676,6 +679,14 @@ function normalizeFooterDocument(
|
|
|
676
679
|
...authoredAlignment(value, "brandAlignment", "footerSettings", tolerateStoredValues),
|
|
677
680
|
...authoredAlignment(value, "asideAlignment", "footerSettings", tolerateStoredValues),
|
|
678
681
|
...authoredAlignment(value, "bottomAlignment", "footerSettings", tolerateStoredValues, true),
|
|
682
|
+
asideCtaStyle: tolerateStoredValues
|
|
683
|
+
? resolveFooterCtaStyle(value.asideCtaStyle)
|
|
684
|
+
: choice(
|
|
685
|
+
value.asideCtaStyle === "" ? undefined : value.asideCtaStyle,
|
|
686
|
+
DEFAULT_FOOTER_CTA_STYLE,
|
|
687
|
+
FOOTER_CTA_STYLES,
|
|
688
|
+
"footerSettings.asideCtaStyle",
|
|
689
|
+
),
|
|
679
690
|
asideSpan: span(value.asideSpan, FOOTER_LIMITS.asideSpanMax, "footerSettings.asideSpan"),
|
|
680
691
|
...(value.asideCta === undefined || value.asideCta === null
|
|
681
692
|
? {}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Generated from shared/footer-cta-styles.ts by scripts/sync-field-validation.mjs. Do not edit.
|
|
2
|
+
export const FOOTER_CTA_STYLES = ["link", "bold-link", "button"];
|
|
3
|
+
export const DEFAULT_FOOTER_CTA_STYLE = FOOTER_CTA_STYLES[0];
|
|
4
|
+
export function resolveFooterCtaStyle(value) {
|
|
5
|
+
return FOOTER_CTA_STYLES.find(option => option === value) ?? DEFAULT_FOOTER_CTA_STYLE;
|
|
6
|
+
}
|
package/src/footer-draft-hash.js
CHANGED
|
@@ -3,7 +3,8 @@ import { createHash } from "node:crypto";
|
|
|
3
3
|
import { SiteAuthoringError } from "./errors.js";
|
|
4
4
|
import { resolveFooterLogoScale } from "./footer-branding.js";
|
|
5
5
|
import { footerAlignmentProfileValues, normalizeFooterLogoBox } from "./footer-alignment.js";
|
|
6
|
-
import { projectFooterContent } from "./footer-content.js";
|
|
6
|
+
import { FOOTER_DRAFT_VERSION, projectFooterContent } from "./footer-content.js";
|
|
7
|
+
import { resolveFooterCtaStyle } from "./footer-cta-styles.js";
|
|
7
8
|
|
|
8
9
|
// Matches the package's document-depth convention (CONTENT_LIMITS.documentDepth):
|
|
9
10
|
// the baseline hashes raw hand-editable JSON, and unbounded nesting would
|
|
@@ -76,7 +77,7 @@ export function stableJson(value) {
|
|
|
76
77
|
// Response-only image URLs stay outside the canonical form.
|
|
77
78
|
export function computeFooterDraftHash(settings = {}) {
|
|
78
79
|
const canonical = [];
|
|
79
|
-
append(canonical,
|
|
80
|
+
append(canonical, FOOTER_DRAFT_VERSION);
|
|
80
81
|
append(canonical, settings.enabled === true);
|
|
81
82
|
append(canonical, settings.showBrand ?? true);
|
|
82
83
|
append(canonical, settings.showBrandText ?? true);
|
|
@@ -109,6 +110,7 @@ export function computeFooterDraftHash(settings = {}) {
|
|
|
109
110
|
const hasAsideCta = settings.asideCta !== undefined && settings.asideCta !== null;
|
|
110
111
|
append(canonical, hasAsideCta);
|
|
111
112
|
if (hasAsideCta) appendLink(canonical, settings.asideCta);
|
|
113
|
+
append(canonical, resolveFooterCtaStyle(settings.asideCtaStyle));
|
|
112
114
|
append(canonical, settings.asideSpan ?? 1);
|
|
113
115
|
appendRichText(canonical, settings.bottomContent);
|
|
114
116
|
appendLinks(canonical, settings.bottomLinks);
|
package/src/footer-fit.js
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
// Generated from shared/footer-fit.ts by scripts/sync-field-validation.mjs. Do not edit.
|
|
2
|
+
import { CONTENT_WELL_MAX_REM, contentInsetPixels } from "./content-inset.js";
|
|
2
3
|
import { FOOTER_LOGO_BOX, resolveFooterLogoScale } from "./footer-branding.js";
|
|
4
|
+
import { resolveFooterCtaStyle } from "./footer-cta-styles.js";
|
|
3
5
|
import { FOOTER_WIDTHS, MAX_FOOTER_FIT_FINDINGS } from "./footer-fit-widths.js";
|
|
4
6
|
import { FOOTER_FONT_METRICS } from "./footer-font-metrics.js";
|
|
5
7
|
export { footerBrandSizeStyles } from "./footer-branding.js";
|
|
6
8
|
export { FOOTER_FIT_WIDTH_LABELS, FOOTER_WIDTHS, MAX_FOOTER_FIT_FINDINGS, } from "./footer-fit-widths.js";
|
|
9
|
+
// The released button uses the default tiny-to-small spacing clamp and a
|
|
10
|
+
// one-pixel field border. The compiled footer oracle checks all five widths.
|
|
11
|
+
export const FOOTER_BUTTON_FIT = Object.freeze({
|
|
12
|
+
labelWeight: "700",
|
|
13
|
+
border: 1,
|
|
14
|
+
minimumPadding: 6,
|
|
15
|
+
maximumPadding: 12.944,
|
|
16
|
+
minimumViewport: 320,
|
|
17
|
+
maximumViewport: 1200,
|
|
18
|
+
});
|
|
19
|
+
export function buttonPaddingInline(viewportWidth) {
|
|
20
|
+
const { minimumPadding, maximumPadding, minimumViewport, maximumViewport } = FOOTER_BUTTON_FIT;
|
|
21
|
+
const ratio = (viewportWidth - minimumViewport) / (maximumViewport - minimumViewport);
|
|
22
|
+
return minimumPadding + Math.min(1, Math.max(0, ratio)) * (maximumPadding - minimumPadding);
|
|
23
|
+
}
|
|
7
24
|
const noto = (fontSize, bold = false) => ({
|
|
8
25
|
fontSize,
|
|
9
26
|
fontWeight: bold ? "700" : "400",
|
|
@@ -19,6 +36,7 @@ const inika = (fontSize) => ({
|
|
|
19
36
|
boldMetricProfile: "inika700",
|
|
20
37
|
});
|
|
21
38
|
function assumption(width, viewportWidth, padding, brandGap, type) {
|
|
39
|
+
const boldLabel = noto(type.normal, true);
|
|
22
40
|
return {
|
|
23
41
|
width,
|
|
24
42
|
viewportWidth,
|
|
@@ -27,14 +45,16 @@ function assumption(width, viewportWidth, padding, brandGap, type) {
|
|
|
27
45
|
brandGap,
|
|
28
46
|
type,
|
|
29
47
|
roles: {
|
|
30
|
-
link:
|
|
48
|
+
link: boldLabel,
|
|
31
49
|
groupHeading: inika(type.normal),
|
|
32
50
|
brand: inika(type.medium),
|
|
33
51
|
brandLarge: inika(type.big),
|
|
34
52
|
brandLargeCompact: inika(type.large),
|
|
35
|
-
asideHeading: inika(type.
|
|
53
|
+
asideHeading: inika(type.normal),
|
|
36
54
|
asideBody: noto(type.normal),
|
|
37
55
|
asideCta: noto(type.normal),
|
|
56
|
+
asideCtaBoldLink: boldLabel,
|
|
57
|
+
asideCtaButton: { ...boldLabel, fontWeight: FOOTER_BUTTON_FIT.labelWeight },
|
|
38
58
|
},
|
|
39
59
|
};
|
|
40
60
|
}
|
|
@@ -113,7 +133,7 @@ export function footerAsideRenders(heading, body, ctaResolves) {
|
|
|
113
133
|
return text(heading?.paragraphs?.[0]) || (body?.paragraphs?.some(text) ?? false) || ctaResolves;
|
|
114
134
|
}
|
|
115
135
|
/** Offline callers treat set targets as present; the deploy supplies its real resolver. */
|
|
116
|
-
export function buildFooterFitInput(settings, brand = {}, resolves = footerTargetIsSet) {
|
|
136
|
+
export function buildFooterFitInput(settings, brand = {}, resolves = footerTargetIsSet, inset) {
|
|
117
137
|
const value = settings ?? {};
|
|
118
138
|
const brandText = value.showBrandText === false ? "" : brand.brandText ?? "";
|
|
119
139
|
const hasLogo = brand.hasLogo === true;
|
|
@@ -127,6 +147,7 @@ export function buildFooterFitInput(settings, brand = {}, resolves = footerTarge
|
|
|
127
147
|
const ctaResolves = Boolean(value.asideCta && resolves(value.asideCta));
|
|
128
148
|
return {
|
|
129
149
|
enabled: value.enabled === true,
|
|
150
|
+
...(inset ? { inset } : {}),
|
|
130
151
|
brand: value.showBrand !== false && (hasLogo || brandText)
|
|
131
152
|
? {
|
|
132
153
|
text: brandText,
|
|
@@ -150,6 +171,7 @@ export function buildFooterFitInput(settings, brand = {}, resolves = footerTarge
|
|
|
150
171
|
heading: paragraph(value.asideHeadingContent?.paragraphs?.[0]),
|
|
151
172
|
body: (value.asideBodyContent?.paragraphs ?? []).map(paragraph),
|
|
152
173
|
ctaLabel: ctaResolves ? value.asideCta?.label : undefined,
|
|
174
|
+
ctaStyle: resolveFooterCtaStyle(value.asideCtaStyle),
|
|
153
175
|
}
|
|
154
176
|
: undefined,
|
|
155
177
|
};
|
|
@@ -271,7 +293,14 @@ export function footerFitFindings(input, assumptions = DEFAULT_FIT_ASSUMPTIONS)
|
|
|
271
293
|
const columns = input.columns.filter(column => column.groups.some(group => group.labels.length));
|
|
272
294
|
const brand = input.brand && (input.brand.hasLogo || input.brand.text) ? input.brand : undefined;
|
|
273
295
|
for (const name of FOOTER_WIDTHS) {
|
|
274
|
-
const
|
|
296
|
+
const original = assumptions[name];
|
|
297
|
+
const a = input.inset && assumptions === DEFAULT_FIT_ASSUMPTIONS
|
|
298
|
+
? {
|
|
299
|
+
...original,
|
|
300
|
+
width: Math.min(original.viewportWidth, CONTENT_WELL_MAX_REM * 16)
|
|
301
|
+
- 2 * contentInsetPixels(input.inset.lightTheme ?? "", input.inset.contentInset, original.viewportWidth),
|
|
302
|
+
}
|
|
303
|
+
: original;
|
|
275
304
|
const stacked = a.width <= 768;
|
|
276
305
|
const middle = !stacked && a.width <= 1024;
|
|
277
306
|
const brandSpan = brand?.span ?? 1;
|
|
@@ -281,18 +310,22 @@ export function footerFitFindings(input, assumptions = DEFAULT_FIT_ASSUMPTIONS)
|
|
|
281
310
|
const regionWidth = (span) => stacked || (middle && totalSpan === 0)
|
|
282
311
|
? a.width
|
|
283
312
|
: span * (a.width - (totalSpan - 1) * a.columnGap) / totalSpan + (span - 1) * a.columnGap;
|
|
313
|
+
const record = (text, region) => {
|
|
314
|
+
const key = `${region}\0${text}`;
|
|
315
|
+
if (seen.has(key))
|
|
316
|
+
return;
|
|
317
|
+
seen.add(key);
|
|
318
|
+
found.push({
|
|
319
|
+
ruleId: "footer.word_breaks",
|
|
320
|
+
severity: "warning",
|
|
321
|
+
subject: text,
|
|
322
|
+
detail: `${name}:${region}`,
|
|
323
|
+
});
|
|
324
|
+
};
|
|
284
325
|
const check = (paragraph, font, width, region) => {
|
|
285
326
|
for (const word of footerFitSegments(paragraph, font, Math.max(0, width))) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
continue;
|
|
289
|
-
seen.add(key);
|
|
290
|
-
found.push({
|
|
291
|
-
ruleId: "footer.word_breaks",
|
|
292
|
-
severity: "warning",
|
|
293
|
-
subject: word.text,
|
|
294
|
-
detail: `${name}:${region}`,
|
|
295
|
-
});
|
|
327
|
+
if (!unsupportedBreakingScript.test(word.text) && word.width > Math.max(0, width))
|
|
328
|
+
record(word.text, region);
|
|
296
329
|
}
|
|
297
330
|
};
|
|
298
331
|
if (brand) {
|
|
@@ -321,7 +354,21 @@ export function footerFitFindings(input, assumptions = DEFAULT_FIT_ASSUMPTIONS)
|
|
|
321
354
|
check(input.aside.heading ?? {}, a.roles.asideHeading, width, "aside");
|
|
322
355
|
for (const p of input.aside.body ?? [])
|
|
323
356
|
check(p, a.roles.asideBody, width, "aside");
|
|
324
|
-
|
|
357
|
+
const { ctaLabel, ctaStyle } = input.aside;
|
|
358
|
+
if (ctaStyle === "button") {
|
|
359
|
+
const label = (ctaLabel ?? "").replace(/[\t\n\f\r ]+/gu, " ").replace(/^ | $/gu, "");
|
|
360
|
+
if (!label || unsupportedBreakingScript.test(label))
|
|
361
|
+
continue;
|
|
362
|
+
const font = a.roles.asideCtaButton;
|
|
363
|
+
const measured = measuredCharacters([...label].map(text => ({ text, profile: font.metricProfile })), font.fontSize);
|
|
364
|
+
const chrome = 2 * (buttonPaddingInline(a.viewportWidth) + FOOTER_BUTTON_FIT.border);
|
|
365
|
+
if (measured.width + chrome > Math.max(0, width))
|
|
366
|
+
record(measured.text, "aside-button");
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
const font = ctaStyle === "bold-link" ? a.roles.asideCtaBoldLink : a.roles.asideCta;
|
|
370
|
+
check(plain(ctaLabel), font, width, "aside");
|
|
371
|
+
}
|
|
325
372
|
}
|
|
326
373
|
}
|
|
327
374
|
return { findings: found.slice(0, MAX_FOOTER_FIT_FINDINGS), total: found.length };
|
package/src/footer-workspace.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { HEX_DIGEST } from "./constants.js";
|
|
2
2
|
import { isCanonicalUuid, SiteAuthoringError } from "./errors.js";
|
|
3
3
|
import { appearanceImageIds } from "./appearance-contract.js";
|
|
4
|
+
import { projectFooterContent } from "./footer-content.js";
|
|
4
5
|
import { footerImageIds } from "./footer-contract.js";
|
|
5
6
|
import { createHash } from "node:crypto";
|
|
6
7
|
import { computeFooterContentHash, computeFooterDraftHash, stableJson } from "./footer-draft-hash.js";
|
|
8
|
+
import { describeJsonDifferences } from "./json-path-diff.js";
|
|
7
9
|
import { readManifest, readMediaManifest, writeManifest } from "./workspace.js";
|
|
8
10
|
|
|
9
11
|
export const FOOTER_SETTINGS_FILE = "settings/site-publishing-preferences.json";
|
|
@@ -87,7 +89,7 @@ export async function advanceFooterManifest(
|
|
|
87
89
|
siteId,
|
|
88
90
|
footerSettings,
|
|
89
91
|
expectedDraftHash,
|
|
90
|
-
{ presentationRevision } = {},
|
|
92
|
+
{ presentationRevision, tagDestinations, authoredTagSlugs, recipeMetadataDestinations } = {},
|
|
91
93
|
) {
|
|
92
94
|
const manifest = await readManifest(workspaceDir, siteId);
|
|
93
95
|
const prior = requireFooterMetadata(manifest);
|
|
@@ -108,7 +110,7 @@ export async function advanceFooterManifest(
|
|
|
108
110
|
// Update both baselines in one manifest write. The caller only supplies a
|
|
109
111
|
// presentation revision when it is already safe for this workspace to own.
|
|
110
112
|
if (presentationRevision !== undefined) {
|
|
111
|
-
manifest.presentation = presentationManifestEntry(presentationRevision);
|
|
113
|
+
manifest.presentation = presentationManifestEntry(presentationRevision, tagDestinations, authoredTagSlugs, recipeMetadataDestinations);
|
|
112
114
|
}
|
|
113
115
|
await writeManifest(workspaceDir, manifest);
|
|
114
116
|
return hash;
|
|
@@ -119,7 +121,7 @@ export async function advanceFooterManifest(
|
|
|
119
121
|
* pulled at (TR00807): what `theme push` sends as its baseline, and what a
|
|
120
122
|
* dry run compares the site's current revision against.
|
|
121
123
|
*/
|
|
122
|
-
export function presentationManifestEntry(revision) {
|
|
124
|
+
export function presentationManifestEntry(revision, tagDestinations, authoredTagSlugs, recipeMetadataDestinations) {
|
|
123
125
|
if (!SHA256.test(revision ?? "")) {
|
|
124
126
|
throw new SiteAuthoringError(
|
|
125
127
|
"api.presentation_contract",
|
|
@@ -127,7 +129,12 @@ export function presentationManifestEntry(revision) {
|
|
|
127
129
|
{ field: "revision" },
|
|
128
130
|
);
|
|
129
131
|
}
|
|
130
|
-
return {
|
|
132
|
+
return {
|
|
133
|
+
revision,
|
|
134
|
+
...(tagDestinations && Object.keys(tagDestinations).length > 0 ? { tagDestinations } : {}),
|
|
135
|
+
...(recipeMetadataDestinations && Object.keys(recipeMetadataDestinations).length > 0 ? { recipeMetadataDestinations } : {}),
|
|
136
|
+
...(authoredTagSlugs === undefined ? {} : { authoredTagSlugs }),
|
|
137
|
+
};
|
|
131
138
|
}
|
|
132
139
|
|
|
133
140
|
/**
|
|
@@ -182,7 +189,7 @@ export async function recordPendingPresentationSave(workspaceDir, siteId, { expe
|
|
|
182
189
|
{ field: "presentation.revision" },
|
|
183
190
|
);
|
|
184
191
|
}
|
|
185
|
-
manifest.presentation = {
|
|
192
|
+
manifest.presentation = { ...manifest.presentation, pending: { expectedRevision, changeSetHash, startedAt } };
|
|
186
193
|
await writeManifest(workspaceDir, manifest);
|
|
187
194
|
}
|
|
188
195
|
|
|
@@ -191,7 +198,7 @@ export async function clearPendingPresentationSave(workspaceDir, siteId) {
|
|
|
191
198
|
const manifest = await readManifest(workspaceDir, siteId);
|
|
192
199
|
const baseline = readPresentationBaseline(manifest);
|
|
193
200
|
if (baseline === undefined || readPendingPresentationSave(manifest) === undefined) return;
|
|
194
|
-
manifest.presentation
|
|
201
|
+
delete manifest.presentation.pending;
|
|
195
202
|
await writeManifest(workspaceDir, manifest);
|
|
196
203
|
}
|
|
197
204
|
|
|
@@ -204,6 +211,36 @@ export function footerManifestEntry(footerSettings) {
|
|
|
204
211
|
};
|
|
205
212
|
}
|
|
206
213
|
|
|
214
|
+
export function hasFooterContentEdits(footer, workspaceFooterSettings) {
|
|
215
|
+
return computeFooterContentHash(workspaceFooterSettings) !== footer.expectedContentHash;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Compare the same content fields and draft token that a footer save uses. */
|
|
219
|
+
export function compareFooterContent(footer, current, proposed) {
|
|
220
|
+
const baseline = footer.expectedDraftHash;
|
|
221
|
+
const currentDraftHash = computeFooterDraftHash(current);
|
|
222
|
+
const { paths, truncated } = describeJsonDifferences(
|
|
223
|
+
{ footerSettings: projectFooterContent(current) },
|
|
224
|
+
{ footerSettings: projectFooterContent(proposed) },
|
|
225
|
+
);
|
|
226
|
+
return {
|
|
227
|
+
changed: paths.length > 0 || truncated,
|
|
228
|
+
draftHash: { baseline, current: currentDraftHash, stale: baseline !== currentDraftHash },
|
|
229
|
+
differences: { file: FOOTER_SETTINGS_FILE, paths, ...(truncated ? { truncated: true } : {}) },
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function reportFooterPreview({ changed, draftHash, differences }, onProgress) {
|
|
234
|
+
if (changed) {
|
|
235
|
+
onProgress(`${differences.file} differs at: ${differences.paths.join(", ")}${differences.truncated ? ", and more" : ""}.`);
|
|
236
|
+
} else {
|
|
237
|
+
onProgress("The workspace's footer content matches the site's draft.");
|
|
238
|
+
}
|
|
239
|
+
if (draftHash.stale) {
|
|
240
|
+
onProgress("The site's footer draft changed since this workspace was pulled. A footer push would refuse. Pull and reconcile the footer before retrying.");
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
207
244
|
/**
|
|
208
245
|
* `theme push` begins with a fresh server read that replaces the workspace
|
|
209
246
|
* footer document, so an unpushed footer-content edit would be silently lost.
|
|
@@ -222,7 +259,7 @@ export function requireFooterContentPushed(footer, workspaceFooterSettings) {
|
|
|
222
259
|
{ field: "footer.expectedContentHash" },
|
|
223
260
|
);
|
|
224
261
|
}
|
|
225
|
-
if (
|
|
262
|
+
if (hasFooterContentEdits(footer, workspaceFooterSettings)) {
|
|
226
263
|
throw new SiteAuthoringError(
|
|
227
264
|
"theme.unpushed_footer_content",
|
|
228
265
|
`${FOOTER_SETTINGS_FILE} carries footer-content edits that 'theme push' would overwrite with the server's copy. `
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { authoredTagSlug } from "./authored-tag-names.js";
|
|
2
|
+
import { SiteAuthoringError } from "./errors.js";
|
|
3
|
+
import { CHECK_AREA, problemsOf } from "./problems.js";
|
|
4
|
+
import { contentDocuments, parseComponentData } from "./typed-pages.js";
|
|
5
|
+
|
|
6
|
+
function listingTags(document) {
|
|
7
|
+
const tags = new Map();
|
|
8
|
+
function visit(node) {
|
|
9
|
+
if (node?.type === "componentBlock" && node.attrs?.componentType === "latest-posts") {
|
|
10
|
+
const data = parseComponentData(node.attrs.componentData);
|
|
11
|
+
const names = Array.isArray(data?.tags) ? data.tags : [];
|
|
12
|
+
for (const [index, name] of names.entries()) {
|
|
13
|
+
if (typeof name !== "string") continue;
|
|
14
|
+
const slug = authoredTagSlug(name);
|
|
15
|
+
if (!tags.has(slug)) tags.set(slug, { name, index });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(node?.content)) node.content.forEach(visit);
|
|
19
|
+
}
|
|
20
|
+
for (const { doc } of contentDocuments(document)) visit(doc);
|
|
21
|
+
return tags;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Pull records the whole catalog. Older or permission-limited pulls cannot prove an unknown tag. */
|
|
25
|
+
export function latestPostsTagProblems(pages, manifest, { sendingOnly = false } = {}) {
|
|
26
|
+
const catalog = manifest.presentation?.authoredTagSlugs;
|
|
27
|
+
if (!Array.isArray(catalog)) return [];
|
|
28
|
+
const knownTags = new Set(catalog);
|
|
29
|
+
// The catalog is from the last pull. A completed pages push leaves a newer per-page baseline.
|
|
30
|
+
for (const page of manifest.pages) {
|
|
31
|
+
if (Array.isArray(page?.baseline?.authoredTagSlugs)) {
|
|
32
|
+
for (const slug of page.baseline.authoredTagSlugs) knownTags.add(slug);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// A tag assigned by another page in this same selection will exist before deploy.
|
|
36
|
+
for (const page of pages) {
|
|
37
|
+
if (page.unchanged) continue;
|
|
38
|
+
for (const slug of page.tagIntent?.slugs ?? []) knownTags.add(slug);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const problems = [];
|
|
42
|
+
for (const page of pages) {
|
|
43
|
+
if (sendingOnly && page.unchanged) continue;
|
|
44
|
+
for (const [slug, { name, index }] of listingTags(page.document)) {
|
|
45
|
+
if (knownTags.has(slug)) continue;
|
|
46
|
+
const error = new SiteAuthoringError(
|
|
47
|
+
"pages.latest_posts_tag_unknown",
|
|
48
|
+
"'" + page.file + "' filters Latest Posts by tag " + JSON.stringify(name)
|
|
49
|
+
+ ", which is absent from the pulled tag catalog. Correct the spelling, assign it to a page in this push, "
|
|
50
|
+
+ "or pull again if the tag was added on the site.",
|
|
51
|
+
{ field: "tags[" + index + "]" },
|
|
52
|
+
);
|
|
53
|
+
problems.push(...problemsOf(error, { area: CHECK_AREA.pages, file: page.file }));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return problems;
|
|
57
|
+
}
|
package/src/page-metadata.js
CHANGED
|
@@ -57,28 +57,30 @@ export function descriptionWarnings(pages, onProgress) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export const PAGE_AUTHOR_UNVERIFIED = "pages.author_unverified";
|
|
60
|
+
export const PAGE_DISPLAY_AUTHOR_UNVERIFIED = "pages.display_author_unverified";
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
63
|
* Warnings for authors an offline run could not confirm (TR01196). The only
|
|
63
64
|
* evidence offline is `authors.json`, which is as old as the last `pull` or
|
|
64
65
|
* `authors list`, so a name missing from it may simply be newer; it is flagged
|
|
65
|
-
* rather than refused, and an online run settles it against the site.
|
|
66
|
+
* rather than refused, and an online run settles it against the site. A display
|
|
67
|
+
* author's handle (TR01402) is held to the same evidence and has its own code.
|
|
66
68
|
*/
|
|
67
69
|
export function authorWarnings(pages, onProgress) {
|
|
68
70
|
const items = [];
|
|
69
71
|
for (const page of pages ?? []) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
for (const [flag, code, label, name] of [
|
|
73
|
+
[page.authorUnverified, PAGE_AUTHOR_UNVERIFIED, "author", page.author],
|
|
74
|
+
[page.displayAuthorUnverified, PAGE_DISPLAY_AUTHOR_UNVERIFIED, "displayAuthor", page.document?.displayAuthor],
|
|
75
|
+
]) {
|
|
76
|
+
if (flag !== true) continue;
|
|
77
|
+
const item = { code, file: page.file, path: displayPagePath(page.pagePath ?? page.path), author: name };
|
|
78
|
+
onProgress(
|
|
79
|
+
`Warning: ${item.file} names ${label} '${item.author}', who is not in authors.json; it may have been added `
|
|
80
|
+
+ "since. 'taproot-site authors list' refreshes it, and 'pages push' checks the name against the site.",
|
|
81
|
+
);
|
|
82
|
+
items.push(item);
|
|
83
|
+
}
|
|
82
84
|
}
|
|
83
85
|
const reported = boundedByBytes(items, 8 * 1024);
|
|
84
86
|
return items.length === 0
|
|
@@ -36,6 +36,7 @@ export const RULE_DESCRIPTION_MISSING = "seo.description_missing";
|
|
|
36
36
|
export const RULE_DESCRIPTION_SHORT = "seo.description_short";
|
|
37
37
|
export const RULE_DESCRIPTION_LONG = "seo.description_long";
|
|
38
38
|
export const RULE_DESCRIPTION_MATCHES_TITLE = "seo.description_matches_title";
|
|
39
|
+
export const RULE_PLACE_REVIEW_AUTHOR_MISSING = "seo.place_review_author_missing";
|
|
39
40
|
export const RULE_SOCIAL_IMAGE_FALLBACK = "seo.social_image_fallback";
|
|
40
41
|
const RULE_ORDER = [
|
|
41
42
|
RULE_H1_MISSING,
|
|
@@ -51,6 +52,7 @@ const RULE_ORDER = [
|
|
|
51
52
|
RULE_DESCRIPTION_SHORT,
|
|
52
53
|
RULE_DESCRIPTION_LONG,
|
|
53
54
|
RULE_DESCRIPTION_MATCHES_TITLE,
|
|
55
|
+
RULE_PLACE_REVIEW_AUTHOR_MISSING,
|
|
54
56
|
RULE_SOCIAL_IMAGE_FALLBACK,
|
|
55
57
|
];
|
|
56
58
|
/** Product guidance for useful metadata, not search-engine limits. */
|
|
@@ -349,6 +351,9 @@ function collectFindings(page) {
|
|
|
349
351
|
if (title && description && title === description) {
|
|
350
352
|
findings.push({ ruleId: RULE_DESCRIPTION_MATCHES_TITLE, severity: "warning", subject: "", detail: "" });
|
|
351
353
|
}
|
|
354
|
+
if (page.reviewAuthorMissing === true) {
|
|
355
|
+
findings.push({ ruleId: RULE_PLACE_REVIEW_AUTHOR_MISSING, severity: "warning", subject: "", detail: "" });
|
|
356
|
+
}
|
|
352
357
|
if (page.freeForm && page.hasCover === false) {
|
|
353
358
|
findings.push({
|
|
354
359
|
ruleId: RULE_SOCIAL_IMAGE_FALLBACK,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Generated from shared/page-tag-badge-modes.ts by scripts/sync-field-validation.mjs. Do not edit.
|
|
2
|
+
export const PAGE_TAG_BADGE_MODES = ["none", "page", "page-and-cards"];
|
|
3
|
+
export const DEFAULT_PAGE_TAG_BADGES = PAGE_TAG_BADGE_MODES[0];
|
|
4
|
+
export function normalizePageTagBadges(value) {
|
|
5
|
+
return PAGE_TAG_BADGE_MODES.find(option => option === value) ?? DEFAULT_PAGE_TAG_BADGES;
|
|
6
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getPage,
|
|
3
|
+
getSiteAuthoringCapabilities,
|
|
4
|
+
PAGE_STATUS_DRAFT,
|
|
5
|
+
PAGE_STATUS_UNKNOWN,
|
|
6
|
+
requireAuthoredTagSnapshot,
|
|
7
|
+
wireAuthoredTagFields,
|
|
8
|
+
} from "./api.js";
|
|
9
|
+
import { authoredTagSlug } from "./authored-tag-names.js";
|
|
10
|
+
import { SiteAuthoringError } from "./errors.js";
|
|
11
|
+
import { CHECK_AREA, collectProblems } from "./problems.js";
|
|
12
|
+
import { ApiError } from "./transport.js";
|
|
13
|
+
import { projectAuthoredTagSnapshot } from "./typed-pages.js";
|
|
14
|
+
import { normalizePageBodyRevision } from "./workspace.js";
|
|
15
|
+
|
|
16
|
+
const TAG_PERMISSION = "site.tags.manage";
|
|
17
|
+
|
|
18
|
+
export function outgoingTagIntent(names, baseline) {
|
|
19
|
+
if (names === undefined) return undefined;
|
|
20
|
+
const slugs = names.map(authoredTagSlug).sort();
|
|
21
|
+
if (Array.isArray(baseline) && slugs.length === baseline.length && slugs.every((slug, index) => slug === baseline[index])) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
return { names, slugs };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function tagWritesPaused() {
|
|
28
|
+
return new SiteAuthoringError(
|
|
29
|
+
"pages.tag_writes_paused",
|
|
30
|
+
"Taproot has paused authored tag writes. Omit 'tags' to send body edits, or ask an administrator to enable tagged writes.",
|
|
31
|
+
{ field: "tags" },
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function tagGrantRequired() {
|
|
36
|
+
return new SiteAuthoringError(
|
|
37
|
+
"pages.tag_grant_required",
|
|
38
|
+
`This credential needs the '${TAG_PERMISSION}' permission to replace or clear authored tags.`,
|
|
39
|
+
{ field: "tags" },
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function requireTagWrites(capabilities) {
|
|
44
|
+
if (capabilities === undefined) {
|
|
45
|
+
throw new SiteAuthoringError(
|
|
46
|
+
"pages.tag_writes_unsupported",
|
|
47
|
+
"This Taproot server predates authored tag writes. Omit 'tags' to send body edits, or upgrade the server.",
|
|
48
|
+
{ field: "tags" },
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
if (!capabilities.authoredTagWritesEnabled) throw tagWritesPaused();
|
|
52
|
+
if (!capabilities.authoredTagWritesPermitted) throw tagGrantRequired();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function tagRevisionConflict(page, bodyChanged) {
|
|
56
|
+
const changed = bodyChanged ? "body" : "authored tags";
|
|
57
|
+
return new SiteAuthoringError(
|
|
58
|
+
bodyChanged ? "pages.tag_body_revision_conflict" : "pages.tag_revision_conflict",
|
|
59
|
+
`The site's ${changed} for '${page.pagePath || "/"}' changed since this workspace reconciled with it. `
|
|
60
|
+
+ `Back up '${page.file}', pull and reconcile with the current site version, then reapply your edits.`,
|
|
61
|
+
{ field: bodyChanged ? "expectedBodyRevision" : "expectedAuthoredTagRevision" },
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function v2BodyRevision(value) {
|
|
66
|
+
const revision = normalizePageBodyRevision(value);
|
|
67
|
+
return revision?.startsWith("v2:") ? revision : undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function readTagWriteFields(client, page) {
|
|
71
|
+
const { tagIntent, tagUpdate } = page;
|
|
72
|
+
if (tagUpdate === undefined) return wireAuthoredTagFields(tagIntent.names);
|
|
73
|
+
|
|
74
|
+
const { target, tagBaseline, bodyRevision } = tagUpdate;
|
|
75
|
+
const status = target.hasDraft ? PAGE_STATUS_DRAFT : target.status;
|
|
76
|
+
if (status === PAGE_STATUS_UNKNOWN) {
|
|
77
|
+
throw new SiteAuthoringError("api.page_status", `Taproot did not report an authoring status for '${page.file}'.`, {
|
|
78
|
+
field: page.file,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const current = await getPage(client, target.pageId, status);
|
|
82
|
+
if (current.pageId !== target.pageId || current.status !== status) {
|
|
83
|
+
throw new SiteAuthoringError("api.page_contract", `Taproot did not return the requested authoring version for '${page.file}'.`, {
|
|
84
|
+
field: page.file,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const snapshot = requireAuthoredTagSnapshot(current);
|
|
88
|
+
const projected = projectAuthoredTagSnapshot(snapshot);
|
|
89
|
+
if ("reason" in projected) {
|
|
90
|
+
throw new SiteAuthoringError(
|
|
91
|
+
"pages.tags_unrepresentable",
|
|
92
|
+
`'${page.file}' has an authored tag set this CLI cannot write. ${projected.reason} `
|
|
93
|
+
+ "Omit 'tags' to send body edits while preserving the site's assignments.",
|
|
94
|
+
{ field: projected.field },
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const expectedBodyRevision = v2BodyRevision(current.bodyRevision);
|
|
99
|
+
if (tagBaseline === undefined || v2BodyRevision(bodyRevision) === undefined) {
|
|
100
|
+
throw new SiteAuthoringError(
|
|
101
|
+
"pages.tag_revision_required",
|
|
102
|
+
`Back up '${page.file}', reconcile it with 'taproot-site pull', then reapply your edits to replace its authored tags.`,
|
|
103
|
+
{ field: "tags" },
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (expectedBodyRevision === undefined) {
|
|
107
|
+
throw new SiteAuthoringError(
|
|
108
|
+
"api.page_contract",
|
|
109
|
+
`Taproot did not return a v2 body revision for '${page.file}'. Pull the page before replacing its authored tags.`,
|
|
110
|
+
{ field: "bodyRevision" },
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
if (expectedBodyRevision !== bodyRevision) throw tagRevisionConflict(page, true);
|
|
114
|
+
if (snapshot.revision !== tagBaseline.authoredTagRevision) throw tagRevisionConflict(page, false);
|
|
115
|
+
return wireAuthoredTagFields(tagIntent.names, {
|
|
116
|
+
expectedAuthoredTagRevision: snapshot.revision,
|
|
117
|
+
expectedBodyRevision,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Resolve every requested replacement before a command can enter its write phase. */
|
|
122
|
+
export async function preflightPageTagWrites(client, siteId, plan, confirmedCapabilities) {
|
|
123
|
+
const tagged = plan.planned.filter((page) => page.tagIntent !== undefined);
|
|
124
|
+
if (tagged.length === 0) return undefined;
|
|
125
|
+
|
|
126
|
+
const capabilities = await collectProblems(plan.problems, { area: CHECK_AREA.pages, file: tagged[0].file }, async () => {
|
|
127
|
+
const current = confirmedCapabilities ?? await getSiteAuthoringCapabilities(client, siteId);
|
|
128
|
+
requireTagWrites(current);
|
|
129
|
+
return current;
|
|
130
|
+
});
|
|
131
|
+
if (capabilities === undefined) return undefined;
|
|
132
|
+
|
|
133
|
+
for (const page of tagged) {
|
|
134
|
+
page.tagFields = await collectProblems(plan.problems, { area: CHECK_AREA.pages, file: page.file }, () =>
|
|
135
|
+
readTagWriteFields(client, page));
|
|
136
|
+
}
|
|
137
|
+
return capabilities;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Match the server's in-transaction refusals to the same remedies as preflight. */
|
|
141
|
+
export function translatePageTagRefusal(error, page) {
|
|
142
|
+
if (page.tagIntent === undefined || !(error instanceof ApiError)) return error;
|
|
143
|
+
if (error.hasField("AuthoredTagWritesPaused")) return tagWritesPaused();
|
|
144
|
+
if (error.hasField("AuthoredTagsPermission") || error.capability?.permission === TAG_PERMISSION) return tagGrantRequired();
|
|
145
|
+
if (error.hasField("ExpectedBodyRevision")) return tagRevisionConflict(page, true);
|
|
146
|
+
if (error.hasField("ExpectedAuthoredTagRevision")) return tagRevisionConflict(page, false);
|
|
147
|
+
return error;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function tagBaselineAfterWrite(previous, page, summary) {
|
|
151
|
+
if (page.tagIntent !== undefined) {
|
|
152
|
+
return { authoredTagRevision: summary.authoredTagRevision, authoredTagSlugs: page.tagIntent.slugs };
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
...(previous?.authoredTagRevision === undefined ? {} : { authoredTagRevision: previous.authoredTagRevision }),
|
|
156
|
+
...(previous?.authoredTagSlugs === undefined ? {} : { authoredTagSlugs: previous.authoredTagSlugs }),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Generated from shared/page-type-tags.ts by scripts/sync-field-validation.mjs. Do not edit.
|
|
2
|
+
/** The reserved tag for each page type, including legacy free-form assignments. */
|
|
3
|
+
export const PAGE_TYPE_TAGS = Object.freeze([
|
|
4
|
+
{ name: "Article", slug: "article" },
|
|
5
|
+
{ name: "Album", slug: "album" },
|
|
6
|
+
{ name: "Recipe", slug: "recipe" },
|
|
7
|
+
{ name: "Place Review", slug: "place-review" },
|
|
8
|
+
{ name: "Free Form", slug: "free-form" },
|
|
9
|
+
]);
|
|
10
|
+
const systemNames = new Set(PAGE_TYPE_TAGS.map(({ name }) => name.toLowerCase()));
|
|
11
|
+
export const SYSTEM_PAGE_TYPE_TAG_SLUGS = Object.freeze(PAGE_TYPE_TAGS.map(({ slug }) => slug));
|
|
12
|
+
const systemSlugs = new Set(SYSTEM_PAGE_TYPE_TAG_SLUGS);
|
|
13
|
+
/** A legacy site can have a reserved name and a different slug, or the reverse. */
|
|
14
|
+
export function isSystemPageTypeTag(name, slug) {
|
|
15
|
+
return systemNames.has(name.toLowerCase()) || systemSlugs.has(slug.toLowerCase());
|
|
16
|
+
}
|