@taprootio/site-authoring 0.42.0 → 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.
Files changed (75) hide show
  1. package/README.md +32 -1
  2. package/examples/riverbend-wellness/settings/site-publishing-preferences.json +3 -0
  3. package/examples/riverbend-wellness/settings/taproot-styles.json +11 -0
  4. package/package.json +4 -3
  5. package/src/api.js +161 -8
  6. package/src/appearance-contract.js +264 -3
  7. package/src/authored-tag-names.js +88 -0
  8. package/src/block-flow.js +103 -1
  9. package/src/brand-color.js +22 -0
  10. package/src/breadcrumb-artwork.js +234 -0
  11. package/src/breadcrumb-separators.js +11 -0
  12. package/src/changelog.json +143 -0
  13. package/src/chrome-features.js +6 -2
  14. package/src/chrome-input.js +1 -0
  15. package/src/chrome-paint-catalog-taproot.json +3 -3
  16. package/src/chrome-report.js +91 -12
  17. package/src/cli.js +45 -16
  18. package/src/content/components.js +27 -4
  19. package/src/content/external-link.js +2 -1
  20. package/src/content/markdown.js +271 -101
  21. package/src/content/tiptap-prosemirror.ts +125 -43
  22. package/src/content/validate-document.js +4 -1
  23. package/src/content-inset.js +48 -0
  24. package/src/errors.js +1 -0
  25. package/src/espalier-shared.js +26 -0
  26. package/src/field-suggestions.js +40 -0
  27. package/src/fixture-init.js +22 -5
  28. package/src/font-catalog.js +11 -1
  29. package/src/footer-brand-inputs.js +22 -3
  30. package/src/footer-content.js +1 -0
  31. package/src/footer-contract.js +11 -0
  32. package/src/footer-cta-styles.js +6 -0
  33. package/src/footer-draft-hash.js +4 -2
  34. package/src/footer-fit.js +62 -15
  35. package/src/footer-workspace.js +44 -7
  36. package/src/latest-posts-tags.js +57 -0
  37. package/src/page-structure-checks.js +5 -0
  38. package/src/page-tag-badge-modes.js +6 -0
  39. package/src/page-tag-writes.js +158 -0
  40. package/src/page-type-tags.js +16 -0
  41. package/src/presentation-reference.js +297 -86
  42. package/src/recipe-page-options.js +22 -0
  43. package/src/recipe-step-contract.js +164 -0
  44. package/src/recipe-step-contract.json +65 -0
  45. package/src/reference-help.js +164 -78
  46. package/src/session.js +39 -24
  47. package/src/setting-reference.js +239 -48
  48. package/src/settings-catalog.js +63 -0
  49. package/src/site-check-findings.js +23 -5
  50. package/src/site-check-rules.json +1 -0
  51. package/src/site-health-findings.js +13 -13
  52. package/src/styling-fixed-values.js +71 -0
  53. package/src/tag-destination-warnings.js +35 -0
  54. package/src/template-token-reach.json +242 -0
  55. package/src/theme-proposals.js +18 -27
  56. package/src/theme-resolve.js +265 -23
  57. package/src/theme-validation.js +118 -7
  58. package/src/token-reach.js +222 -0
  59. package/src/typed-page-reference.js +72 -15
  60. package/src/typed-pages.js +171 -71
  61. package/src/verbs/deploy.js +6 -0
  62. package/src/verbs/footer-push.js +30 -5
  63. package/src/verbs/forms-push.js +11 -3
  64. package/src/verbs/pages-delete.js +19 -10
  65. package/src/verbs/pages-push.js +125 -36
  66. package/src/verbs/plan.js +10 -4
  67. package/src/verbs/pull.js +277 -67
  68. package/src/verbs/staging-review.js +27 -1
  69. package/src/verbs/status.js +22 -0
  70. package/src/verbs/theme-push.js +93 -25
  71. package/src/verbs/theme-resolve.js +189 -55
  72. package/src/verbs/validate.js +6 -5
  73. package/src/workspace-check.js +35 -3
  74. package/src/workspace.js +37 -1
  75. package/test/fixtures/default-site-theme.json +516 -0
@@ -81,6 +81,7 @@ export const SITE_CHECK_WORDING = Object.freeze({
81
81
  "seo.description_missing": () => "has no description; add a short account of what the page offers",
82
82
  "seo.description_short": (finding) => `has a description of ${finding.detail} characters; consider adding useful detail (guidance: ${DESCRIPTION_MINIMUM_LENGTH}–${DESCRIPTION_WARN_LENGTH})`,
83
83
  "seo.description_long": (finding) => `has a description of ${finding.detail} characters; consider shortening it (guidance: ${DESCRIPTION_MINIMUM_LENGTH}–${DESCRIPTION_WARN_LENGTH})`,
84
+ "seo.place_review_author_missing": () => "has no credited reviewer; Google review snippets require a reviewer name",
84
85
  "seo.description_matches_title": () => "has a description that repeats its title; explain what readers will find",
85
86
  "footer.word_breaks": (finding) => footerFindingWords(finding),
86
87
  "brand.logo_on_surface": finding => {
@@ -120,6 +121,7 @@ export const SITE_CHECK_REMEDIES = Object.freeze({
120
121
  "seo.description_missing": `Add a short description of what the page offers, ${AFTER_PAGE_FIX}.`,
121
122
  "seo.description_short": `Add useful detail so the description runs ${DESCRIPTION_MINIMUM_LENGTH}–${DESCRIPTION_WARN_LENGTH} characters, ${AFTER_PAGE_FIX}.`,
122
123
  "seo.description_long": `Shorten the description to ${DESCRIPTION_MINIMUM_LENGTH}–${DESCRIPTION_WARN_LENGTH} characters, ${AFTER_PAGE_FIX}.`,
124
+ "seo.place_review_author_missing": `Assign a reviewer on the page, ${AFTER_PAGE_FIX}.`,
123
125
  "seo.description_matches_title": `Rewrite the description to say what readers will find, not repeat the title, ${AFTER_PAGE_FIX}.`,
124
126
  });
125
127
 
@@ -151,6 +153,9 @@ function footerFindingWords(finding) {
151
153
  const widthName = Object.hasOwn(FOOTER_FIT_WIDTH_LABELS, width)
152
154
  ? FOOTER_FIT_WIDTH_LABELS[width].toLowerCase()
153
155
  : undefined;
156
+ if (region === "aside-button") {
157
+ return `the footer button '${finding.subject}' may overflow ${widthName ? `at ${widthName} width` : "at this width"}. Shorten its label or choose a link style`;
158
+ }
154
159
  const advice = FOOTER_REGION_ADVICE[region] ?? "Widen the region or shorten the text";
155
160
  return `'${finding.subject}' may break mid-word ${widthName === undefined ? "at this width" : `at ${widthName} width`}. ${advice}`;
156
161
  }
@@ -163,6 +168,18 @@ export function describeSiteFinding(finding) {
163
168
 
164
169
  // Progress names this many; the JSON list is bounded by bytes instead.
165
170
  export const MAXIMUM_PROGRESS_LINES = 20;
171
+ const metadataRules = new Set(METADATA_RULE_IDS);
172
+
173
+ function progressPriority({ rule, severity }) {
174
+ if (severity === "error") return 0;
175
+ return metadataRules.has(rule) ? 2 : 1;
176
+ }
177
+
178
+ /** Keep publish warnings ahead of recurring title and description advice in the capped terminal list. */
179
+ export function siteFindingsForProgress(items) {
180
+ return items.toSorted((left, right) => progressPriority(left) - progressPriority(right))
181
+ .slice(0, MAXIMUM_PROGRESS_LINES);
182
+ }
166
183
 
167
184
  const rulesRunningAt = (point) => SITE_CHECK_RULES.filter((rule) => rule.runsAt.includes(point)).map((rule) => rule.id);
168
185
 
@@ -179,6 +196,7 @@ function structureFindingsFor(page) {
179
196
  return pageStructureFindings(
180
197
  {
181
198
  freeForm,
199
+ reviewAuthorMissing: page.reviewAuthorMissing,
182
200
  body: freeForm ? page.document : undefined,
183
201
  ...localAuthoringMetadata({
184
202
  title: page.title,
@@ -220,8 +238,7 @@ export function evaluateOfflineSiteChecks({
220
238
  for (const finding of [...linkFindings, ...structureFindingsFor(page)]) found.push({ page, finding });
221
239
  }
222
240
  for (const finding of footer.findings) found.push({ finding });
223
- // Errors first, then in catalogue order, so the bounded list and the progress lines keep the rules that
224
- // matter most when a large site raises a frequent one (a missing description) on every page.
241
+ // Keep severity and catalogue order in the byte-capped JSON list.
225
242
  const catalogueOrder = (ruleId) => SITE_CHECK_RULES.findIndex((rule) => rule.id === ruleId);
226
243
  const severityOrder = (finding) => (finding.severity === "error" ? 0 : 1);
227
244
  found.sort((left, right) =>
@@ -240,11 +257,12 @@ export function evaluateOfflineSiteChecks({
240
257
  subject,
241
258
  ...(finding.detail === "" ? {} : { detail: finding.detail }),
242
259
  };
243
- if (items.length < MAXIMUM_PROGRESS_LINES) {
244
- onProgress(`Warning: ${item.file} ${describeSiteFinding({ ...finding, subject })}.`);
245
- }
246
260
  items.push(item);
247
261
  }
262
+ for (const item of siteFindingsForProgress(items)) {
263
+ const words = describeSiteFinding({ ruleId: item.rule, subject: item.subject, detail: item.detail ?? "" });
264
+ onProgress(`Warning: ${item.file} ${words}.`);
265
+ }
248
266
  if (items.length > MAXIMUM_PROGRESS_LINES) {
249
267
  onProgress(`Warning: ${items.length - MAXIMUM_PROGRESS_LINES} more site check finding(s); see findings.`);
250
268
  }
@@ -33,6 +33,7 @@
33
33
  { "id": "seo.description_short", "severity": "warning", "scope": "document", "runsAt": ["validate", "edit", "deploy", "health"], "subject": "none", "detail": "character_count" },
34
34
  { "id": "seo.description_long", "severity": "warning", "scope": "document", "runsAt": ["validate", "edit", "deploy", "health"], "subject": "none", "detail": "character_count" },
35
35
  { "id": "seo.description_matches_title", "severity": "warning", "scope": "document", "runsAt": ["validate", "edit", "deploy", "health"], "subject": "none", "detail": "none" },
36
+ { "id": "seo.place_review_author_missing", "severity": "warning", "scope": "document", "appliesTo": ["place_review"], "runsAt": ["validate", "deploy", "health"], "subject": "none", "detail": "none" },
36
37
  { "id": "seo.social_image_fallback", "severity": "warning", "scope": "document", "appliesTo": ["free_form"], "runsAt": ["edit"], "subject": "none", "detail": "social_image_source" },
37
38
  { "id": "footer.word_breaks", "severity": "warning", "scope": "site", "runsAt": ["validate", "edit", "deploy", "health"], "subject": "footer_word", "detail": "width_and_region" },
38
39
  { "id": "brand.logo_on_surface", "severity": "warning", "scope": "site", "runsAt": ["validate"], "subject": "surface", "detail": "scheme_and_variant" },
@@ -1,7 +1,7 @@
1
1
  import { visitImageDescriptionObjects, imageDescriptionImageId } from "./content/image-description-document.js";
2
2
  import { CLI_BINARY_NAME } from "./constants.js";
3
3
  import { sanitizeDiagnostic } from "./errors.js";
4
- import { AFTER_PAGE_FIX, describeSiteFinding, MAXIMUM_PROGRESS_LINES, remedyForRule } from "./site-check-findings.js";
4
+ import { AFTER_PAGE_FIX, describeSiteFinding, MAXIMUM_PROGRESS_LINES, remedyForRule, siteFindingsForProgress } from "./site-check-findings.js";
5
5
  import { displayPagePath } from "./workspace.js";
6
6
 
7
7
  /**
@@ -231,22 +231,22 @@ export function reportHealthProgress(onProgress, { environment, checkedAt, statu
231
231
  // Every value here ends up on a terminal, and some come from the manifest or the server unchecked, so each is
232
232
  // cleaned for display. The JSON result keeps the original values.
233
233
  const safe = (value, fallback = "") => sanitizeDiagnostic(value, fallback);
234
- const worth = [
235
- ...findings.filter((item) => item.newSinceProduction !== false).map((item) =>
236
- `Warning: ${safe(item.file ?? item.path, "site")} ${
237
- describeSiteFinding({ ruleId: safe(item.rule), subject: safe(item.subject), detail: safe(item.detail) })
238
- }. Fix: ${safe(item.fix)}`
239
- ),
240
- ...imageFindings.filter((item) => item.newSinceProduction !== false).map(imageFindingLine),
241
- ];
234
+ const newFindings = [...findings, ...imageFindings].filter((item) => item.newSinceProduction !== false);
242
235
  const scope = environment === "staging" && compared === false
243
236
  ? "not compared with production, so every warning is listed"
244
237
  : environment === "staging"
245
- ? `${worth.length} new since production`
238
+ ? `${newFindings.length} new since production`
246
239
  : "production";
247
240
  onProgress(`Site health (${environment}, checked ${checkedAt}): ${total} finding(s), ${scope}.${incomplete}`);
248
- for (const line of worth.slice(0, MAXIMUM_PROGRESS_LINES)) onProgress(line);
249
- if (worth.length > MAXIMUM_PROGRESS_LINES) {
250
- onProgress(`Warning: ${worth.length - MAXIMUM_PROGRESS_LINES} more Site Health finding(s); see findings and imageFindings.`);
241
+ for (const item of siteFindingsForProgress(newFindings)) {
242
+ if ("imageId" in item) {
243
+ onProgress(imageFindingLine(item));
244
+ continue;
245
+ }
246
+ const words = describeSiteFinding({ ruleId: safe(item.rule), subject: safe(item.subject), detail: safe(item.detail) });
247
+ onProgress(`Warning: ${safe(item.file ?? item.path, "site")} ${words}. Fix: ${safe(item.fix)}`);
248
+ }
249
+ if (newFindings.length > MAXIMUM_PROGRESS_LINES) {
250
+ onProgress(`Warning: ${newFindings.length - MAXIMUM_PROGRESS_LINES} more Site Health finding(s); see findings and imageFindings.`);
251
251
  }
252
252
  }
@@ -0,0 +1,71 @@
1
+ function fact(name, value, where, source) {
2
+ return Object.freeze({ name, value, where, source });
3
+ }
4
+
5
+ const structuredPageTitleMargins = {
6
+ above: "0",
7
+ belowWithoutMetadata: "0.7em",
8
+ metadataGap: { factor: 0.9, token: "--esp-size-small", scaledBy: "blockSpacing" },
9
+ };
10
+
11
+ export const APPEARANCE_FIXED_VALUES = Object.freeze([
12
+ fact(
13
+ "header.logoHeight",
14
+ {
15
+ barBase: { factor: 4.5, token: "--esp-size-small" },
16
+ brandLogoSize: { standard: 0.72, large: 0.85, full: 1 },
17
+ },
18
+ "The expanded limit multiplies the bar base by headerHeightMultiplier and the brandLogoSize factor. A fixed header "
19
+ + "shrinks toward headerMinHeightMultiplier on scroll. Set --esp-header-brand-logo-max-width in theme componentProperties "
20
+ + "to change the width cap for regular and compact artwork. With the default 12rem cap, a 5:1 logo renders at most "
21
+ + "2.4rem (about 38px) tall at rest. brandHoverGrow enlarges the painted brand on hover.",
22
+ "esp-header --esp-header-brand-logo-size and Taproot header settings",
23
+ ),
24
+ fact(
25
+ "blockFlow.outsideFlowContainers",
26
+ { above: "--esp-size-small-to-normal", below: "--esp-size-tiny-to-small", structuredPageTitle: structuredPageTitleMargins },
27
+ "The fallback for plain h1–h5 headings outside a flow. Article, album, place review and recipe page titles "
28
+ + "have no top margin. The title-to-metadata and byline-to-tags gaps both use 0.9 × --esp-size-small, "
29
+ + "scaled by Block spacing. headingH1SpaceAfter can set the title-to-metadata gap in rem. "
30
+ + "A title with no metadata keeps a 0.7em bottom margin. Recipe card headings, the footer aside, the legal title, legal "
31
+ + "Contents and Summary of changes headings, and banners set their own margins.",
32
+ "esp-root and Taproot page styles",
33
+ ),
34
+ ]);
35
+
36
+ const underline = Object.freeze({ rest: "underline", hover: "underline" });
37
+ const auto = Object.freeze({ rest: "auto", hover: "auto" });
38
+
39
+ export const FOOTER_LINK_DEFAULTS = Object.freeze({
40
+ column: { decoration: underline, offset: { rest: "0.18em", hover: "0.18em" }, thickness: auto },
41
+ bottom: { decoration: underline, offset: auto, thickness: auto },
42
+ brand: { decoration: { rest: "none", hover: "underline" }, offset: { rest: "auto", hover: "0.18em" }, thickness: auto },
43
+ asideCta: { decoration: underline, offset: auto, thickness: auto },
44
+ asideRichText: { decoration: underline, offset: auto, thickness: auto },
45
+ bottomRichText: { decoration: underline, offset: auto, thickness: auto },
46
+ social: { decoration: { rest: "underline", hover: "none" }, offset: auto, thickness: auto },
47
+ });
48
+
49
+ export const FOOTER_FIXED_VALUES = Object.freeze([
50
+ fact(
51
+ "footer.layoutBreakpoints",
52
+ { wide: "above 64rem (1024px)", brandRow: "above 48rem (768px) through 64rem (1024px)", stacked: "48rem (768px) or less" },
53
+ "The footer content-box width selects the layout. A 768px viewport stacks.",
54
+ "esp-footer container query",
55
+ ),
56
+ fact(
57
+ "footer.linkWeights",
58
+ { column: "700", bottom: "700", brand: "400", asideCta: "400", asideCtaBoldLink: "700", asideRichText: "700", bottomRichText: "700", social: "400" },
59
+ "Weights in a newly created site's theme. Unclassed links use bold. In asideCtaStyle, link uses the body weight and "
60
+ + "bold-link uses bold. Social links use the body weight. The configured brand uses the brand weight, with heading weight as its CSS fallback.",
61
+ "esp-root, esp-footer and Taproot's aside action",
62
+ ),
63
+ ]);
64
+
65
+ export function formatFixedValues(fixedValues) {
66
+ if (!fixedValues?.length) return "";
67
+ return "\n\nFixed values\n" + fixedValues.map(({ name, value, where, source }) => {
68
+ const display = typeof value === "string" ? value : JSON.stringify(value);
69
+ return ` ${name} — ${display}\n ${where}\n Source: ${source}`;
70
+ }).join("\n") + "\n";
71
+ }
@@ -0,0 +1,35 @@
1
+ import { isGonePage } from "./api.js";
2
+ import { boundedByBytes } from "./session.js";
3
+
4
+ const DESTINATION_SETTINGS = ["tagDestinations", "recipeMetadataDestinations"];
5
+
6
+ export function tagDestinationEntries(preferences) {
7
+ return DESTINATION_SETTINGS.flatMap((setting) =>
8
+ Object.entries(preferences?.[setting] ?? {})
9
+ .filter(([, resourceId]) => typeof resourceId === "string" && resourceId !== "")
10
+ .map(([name, resourceId]) => ({ setting, name, resourceId })),
11
+ );
12
+ }
13
+
14
+ export function missingTagDestinations(preferences, manifest) {
15
+ if (manifest === undefined || manifest.pagesTruncated === true) return [];
16
+ const knownPages = new Set(manifest.pages.filter((page) => page && !isGonePage(page)).map((page) => page.resourceId));
17
+ return tagDestinationEntries(preferences).filter(({ resourceId }) => !knownPages.has(resourceId));
18
+ }
19
+
20
+ export function reportTagDestinationWarnings(items, onProgress, deletingPath) {
21
+ if (items.length === 0) return undefined;
22
+ const report = { count: items.length, ...boundedByBytes(items, 8 * 1024) };
23
+ const location = deletingPath === undefined
24
+ ? "has a destination page absent from this workspace"
25
+ : "points to '" + deletingPath + "'";
26
+ for (const { setting, name } of report.items) {
27
+ onProgress(
28
+ "Warning: " + setting + " entry " + JSON.stringify(name) + " " + location
29
+ + ". Badges render as plain text when the destination is unavailable. Update the destination in "
30
+ + "settings/site-publishing-preferences.json and run 'taproot-site theme push'.",
31
+ );
32
+ }
33
+ if (report.truncated === true) onProgress("Additional tag destination warnings: " + (report.count - report.items.length) + ".");
34
+ return report;
35
+ }