@taprootio/site-authoring 0.41.1 → 0.55.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 +50 -0
- 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 +170 -11
- package/src/appearance-contract.js +278 -8
- package/src/authored-tag-names.js +88 -0
- package/src/block-flow.js +103 -1
- package/src/brand-color.js +39 -4
- package/src/breadcrumb-artwork.js +234 -0
- package/src/breadcrumb-separators.js +11 -0
- package/src/changelog.json +154 -0
- package/src/chrome-features.js +152 -0
- package/src/chrome-input.js +147 -0
- package/src/chrome-output.js +92 -0
- package/src/chrome-paint-catalog-taproot.json +52 -0
- package/src/chrome-report.js +173 -0
- package/src/cli.js +48 -17
- 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 +25 -2
- package/src/footer-content.js +38 -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 +60 -16
- package/src/header-presentation.js +16 -0
- package/src/latest-posts-tags.js +57 -0
- 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 +312 -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 +164 -78
- 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 +25 -5
- package/src/site-check-rules.json +3 -1
- package/src/site-health-findings.js +13 -13
- package/src/site-navigation-groups.js +70 -0
- 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 +305 -51
- package/src/theme-validation.js +126 -6
- package/src/token-reach.js +222 -0
- package/src/typed-page-reference.js +72 -15
- package/src/typed-pages.js +171 -71
- 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/pages-delete.js +19 -10
- package/src/verbs/pages-push.js +125 -36
- package/src/verbs/plan.js +10 -4
- package/src/verbs/pull.js +277 -67
- package/src/verbs/staging-review.js +27 -1
- package/src/verbs/status.js +22 -0
- package/src/verbs/theme-push.js +249 -120
- package/src/verbs/theme-resolve.js +310 -47
- package/src/verbs/validate.js +71 -17
- package/src/workspace-check.js +37 -4
- package/src/workspace.js +37 -1
- package/test/fixtures/default-site-theme.json +516 -0
package/src/footer-content.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// Generated from shared/footer-content.ts by scripts/sync-field-validation.mjs. Do not edit.
|
|
2
|
+
import { isSafeUrl } from "./url-safety.js";
|
|
3
|
+
export const FOOTER_DRAFT_VERSION = "footer-draft-v9";
|
|
2
4
|
/** These fields belong to presentation; footer content saves and dirty checks leave them alone. */
|
|
3
5
|
export const FOOTER_PRESENTATION_FIELDS = ["context", "logoVariant"];
|
|
4
6
|
/** Preserve raw content values; callers decide whether their document needs normalization. */
|
|
@@ -8,3 +10,39 @@ export function projectFooterContent(settings) {
|
|
|
8
10
|
delete content[field];
|
|
9
11
|
return content;
|
|
10
12
|
}
|
|
13
|
+
/** Live settings without a path inventory can only assume an authored page target exists. */
|
|
14
|
+
export function resolveFooterTarget(target, pathsByResourceId) {
|
|
15
|
+
const pageResourceId = target.pageResourceId?.trim() ?? "";
|
|
16
|
+
const externalUrl = target.externalUrl?.trim() ?? "";
|
|
17
|
+
if (Boolean(pageResourceId) === Boolean(externalUrl))
|
|
18
|
+
return null;
|
|
19
|
+
if (pageResourceId) {
|
|
20
|
+
if (pathsByResourceId === undefined)
|
|
21
|
+
return "/";
|
|
22
|
+
const path = pathsByResourceId.get(pageResourceId);
|
|
23
|
+
return path && isSafeUrl(path) ? path : null;
|
|
24
|
+
}
|
|
25
|
+
return normalizeExternalTargetUrl(externalUrl);
|
|
26
|
+
}
|
|
27
|
+
/** Preserve authored contact URLs. URL.toString() can re-encode phone or address punctuation. */
|
|
28
|
+
function normalizeExternalTargetUrl(candidate) {
|
|
29
|
+
// The generic safe-link rule also allows relative paths. An external footer
|
|
30
|
+
// target must be absolute, and the write paths also refuse C1 controls.
|
|
31
|
+
if (!candidate || !isSafeUrl(candidate) || /[\u0080-\u009f]/u.test(candidate))
|
|
32
|
+
return null;
|
|
33
|
+
let parsed;
|
|
34
|
+
try {
|
|
35
|
+
parsed = new URL(candidate);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
if (parsed.protocol === "http:" || parsed.protocol === "https:") {
|
|
41
|
+
return parsed.username || parsed.password || !parsed.hostname ? null : parsed.toString();
|
|
42
|
+
}
|
|
43
|
+
if (parsed.protocol !== "mailto:" && parsed.protocol !== "tel:")
|
|
44
|
+
return null;
|
|
45
|
+
if (candidate.slice(candidate.indexOf(":") + 1).startsWith("//"))
|
|
46
|
+
return null;
|
|
47
|
+
return parsed.pathname.length > 0 ? candidate : null;
|
|
48
|
+
}
|
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";
|
|
@@ -54,15 +56,22 @@ export async function readFooterWorkspaceContext(workspaceDir, siteId) {
|
|
|
54
56
|
const manifest = await readManifest(workspaceDir, siteId);
|
|
55
57
|
const footer = requireFooterMetadata(manifest);
|
|
56
58
|
const mediaManifest = await readMediaManifest(workspaceDir, siteId);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
requireAppearanceMetadata(manifest, { required: false, code: "footer.pull_required" });
|
|
60
|
+
return { manifest, mediaManifest, footer, ...appearanceResourceIds(manifest, mediaManifest) };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Collect the identities present in the available, site-bound inventory. */
|
|
64
|
+
export function appearanceResourceIds(manifest, mediaManifest) {
|
|
65
|
+
const knownPageResourceIds = manifest === undefined
|
|
66
|
+
? undefined
|
|
67
|
+
: new Set(manifest.pages.map((page) => page?.resourceId).filter(isCanonicalUuid));
|
|
68
|
+
const imageIds = [manifest?.footer?.imageIds, manifest?.appearance?.imageIds]
|
|
69
|
+
.flatMap((ids) => Array.isArray(ids) ? ids : []);
|
|
70
|
+
const knownImageIds = new Set([
|
|
71
|
+
...imageIds,
|
|
72
|
+
...Object.values(mediaManifest?.media ?? {}).map((item) => item?.imageId),
|
|
73
|
+
].filter(isCanonicalUuid));
|
|
74
|
+
return { knownPageResourceIds, knownImageIds };
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
export async function readAppearanceWorkspaceContext(workspaceDir, siteId) {
|
|
@@ -80,7 +89,7 @@ export async function advanceFooterManifest(
|
|
|
80
89
|
siteId,
|
|
81
90
|
footerSettings,
|
|
82
91
|
expectedDraftHash,
|
|
83
|
-
{ presentationRevision } = {},
|
|
92
|
+
{ presentationRevision, tagDestinations, authoredTagSlugs, recipeMetadataDestinations } = {},
|
|
84
93
|
) {
|
|
85
94
|
const manifest = await readManifest(workspaceDir, siteId);
|
|
86
95
|
const prior = requireFooterMetadata(manifest);
|
|
@@ -101,7 +110,7 @@ export async function advanceFooterManifest(
|
|
|
101
110
|
// Update both baselines in one manifest write. The caller only supplies a
|
|
102
111
|
// presentation revision when it is already safe for this workspace to own.
|
|
103
112
|
if (presentationRevision !== undefined) {
|
|
104
|
-
manifest.presentation = presentationManifestEntry(presentationRevision);
|
|
113
|
+
manifest.presentation = presentationManifestEntry(presentationRevision, tagDestinations, authoredTagSlugs, recipeMetadataDestinations);
|
|
105
114
|
}
|
|
106
115
|
await writeManifest(workspaceDir, manifest);
|
|
107
116
|
return hash;
|
|
@@ -112,7 +121,7 @@ export async function advanceFooterManifest(
|
|
|
112
121
|
* pulled at (TR00807): what `theme push` sends as its baseline, and what a
|
|
113
122
|
* dry run compares the site's current revision against.
|
|
114
123
|
*/
|
|
115
|
-
export function presentationManifestEntry(revision) {
|
|
124
|
+
export function presentationManifestEntry(revision, tagDestinations, authoredTagSlugs, recipeMetadataDestinations) {
|
|
116
125
|
if (!SHA256.test(revision ?? "")) {
|
|
117
126
|
throw new SiteAuthoringError(
|
|
118
127
|
"api.presentation_contract",
|
|
@@ -120,7 +129,12 @@ export function presentationManifestEntry(revision) {
|
|
|
120
129
|
{ field: "revision" },
|
|
121
130
|
);
|
|
122
131
|
}
|
|
123
|
-
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
|
+
};
|
|
124
138
|
}
|
|
125
139
|
|
|
126
140
|
/**
|
|
@@ -175,7 +189,7 @@ export async function recordPendingPresentationSave(workspaceDir, siteId, { expe
|
|
|
175
189
|
{ field: "presentation.revision" },
|
|
176
190
|
);
|
|
177
191
|
}
|
|
178
|
-
manifest.presentation = {
|
|
192
|
+
manifest.presentation = { ...manifest.presentation, pending: { expectedRevision, changeSetHash, startedAt } };
|
|
179
193
|
await writeManifest(workspaceDir, manifest);
|
|
180
194
|
}
|
|
181
195
|
|
|
@@ -184,7 +198,7 @@ export async function clearPendingPresentationSave(workspaceDir, siteId) {
|
|
|
184
198
|
const manifest = await readManifest(workspaceDir, siteId);
|
|
185
199
|
const baseline = readPresentationBaseline(manifest);
|
|
186
200
|
if (baseline === undefined || readPendingPresentationSave(manifest) === undefined) return;
|
|
187
|
-
manifest.presentation
|
|
201
|
+
delete manifest.presentation.pending;
|
|
188
202
|
await writeManifest(workspaceDir, manifest);
|
|
189
203
|
}
|
|
190
204
|
|
|
@@ -197,6 +211,36 @@ export function footerManifestEntry(footerSettings) {
|
|
|
197
211
|
};
|
|
198
212
|
}
|
|
199
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
|
+
|
|
200
244
|
/**
|
|
201
245
|
* `theme push` begins with a fresh server read that replaces the workspace
|
|
202
246
|
* footer document, so an unpushed footer-content edit would be silently lost.
|
|
@@ -215,7 +259,7 @@ export function requireFooterContentPushed(footer, workspaceFooterSettings) {
|
|
|
215
259
|
{ field: "footer.expectedContentHash" },
|
|
216
260
|
);
|
|
217
261
|
}
|
|
218
|
-
if (
|
|
262
|
+
if (hasFooterContentEdits(footer, workspaceFooterSettings)) {
|
|
219
263
|
throw new SiteAuthoringError(
|
|
220
264
|
"theme.unpushed_footer_content",
|
|
221
265
|
`${FOOTER_SETTINGS_FILE} carries footer-content edits that 'theme push' would overwrite with the server's copy. `
|
|
@@ -28,6 +28,22 @@ export function canUseCompactHeaderLogo(position, multiplier, hasRegularLogo, mi
|
|
|
28
28
|
return position === "fixed" && hasRegularLogo && height !== null
|
|
29
29
|
&& height.tenths > resolveHeaderMinHeightMultiplier(minimum, multiplier).tenths;
|
|
30
30
|
}
|
|
31
|
+
/** Read the same header settings when building the page and when auditing its paint. */
|
|
32
|
+
export function resolveHeaderChromePresentation(settings) {
|
|
33
|
+
const layout = settings?.headerLayout;
|
|
34
|
+
return {
|
|
35
|
+
layout: layout === "centered-brand" || layout === "centered-menu" || layout === "minimal" ? layout : "standard",
|
|
36
|
+
heightMultiplier: resolveHeaderHeightMultiplier(settings?.headerHeightMultiplier).scale,
|
|
37
|
+
minHeightMultiplier: resolveHeaderMinHeightMultiplier(settings?.headerMinHeightMultiplier, settings?.headerHeightMultiplier).scale,
|
|
38
|
+
compactSizeStandard: settings?.headerPosition === "fixed",
|
|
39
|
+
compactOnScroll: canUseCompactHeaderLogo(settings?.headerPosition, settings?.headerHeightMultiplier, true, settings?.headerMinHeightMultiplier),
|
|
40
|
+
menuDisplay: settings?.navMenuDisplay === "drawer" ? "drawer" : "auto",
|
|
41
|
+
navDrawerStyle: settings?.navDrawerStyle === "panel" ? "panel" : "full-screen",
|
|
42
|
+
brandText: settings?.brandText ?? "",
|
|
43
|
+
showBrandText: settings?.showBrandText !== false,
|
|
44
|
+
showThemeToggle: settings?.showThemeToggle === true,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
31
47
|
/** Keep each scheme's selected source and reserved ratio together through fallback. */
|
|
32
48
|
export function resolveHeaderLogoPairs(input) {
|
|
33
49
|
const pair = (url = "", aspectRatio = "") => ({ url, aspectRatio: url ? aspectRatio : "" });
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|