@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.
Files changed (80) hide show
  1. package/README.md +110 -12
  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 +242 -23
  6. package/src/appearance-contract.js +264 -3
  7. package/src/authored-tag-names.js +88 -0
  8. package/src/authors-contract.js +71 -3
  9. package/src/block-flow.js +103 -1
  10. package/src/brand-color.js +22 -0
  11. package/src/breadcrumb-artwork.js +234 -0
  12. package/src/breadcrumb-separators.js +11 -0
  13. package/src/changelog.json +160 -0
  14. package/src/chrome-features.js +6 -2
  15. package/src/chrome-input.js +1 -0
  16. package/src/chrome-paint-catalog-taproot.json +3 -3
  17. package/src/chrome-report.js +91 -12
  18. package/src/cli.js +136 -38
  19. package/src/constants.js +1 -0
  20. package/src/content/components.js +27 -4
  21. package/src/content/external-link.js +2 -1
  22. package/src/content/markdown.js +271 -101
  23. package/src/content/tiptap-prosemirror.ts +125 -43
  24. package/src/content/validate-document.js +4 -1
  25. package/src/content-inset.js +48 -0
  26. package/src/errors.js +1 -0
  27. package/src/espalier-shared.js +26 -0
  28. package/src/field-suggestions.js +40 -0
  29. package/src/fixture-init.js +22 -5
  30. package/src/font-catalog.js +11 -1
  31. package/src/footer-brand-inputs.js +22 -3
  32. package/src/footer-content.js +1 -0
  33. package/src/footer-contract.js +11 -0
  34. package/src/footer-cta-styles.js +6 -0
  35. package/src/footer-draft-hash.js +4 -2
  36. package/src/footer-fit.js +62 -15
  37. package/src/footer-workspace.js +44 -7
  38. package/src/latest-posts-tags.js +57 -0
  39. package/src/page-metadata.js +15 -13
  40. package/src/page-structure-checks.js +5 -0
  41. package/src/page-tag-badge-modes.js +6 -0
  42. package/src/page-tag-writes.js +158 -0
  43. package/src/page-type-tags.js +16 -0
  44. package/src/presentation-reference.js +297 -86
  45. package/src/recipe-page-options.js +22 -0
  46. package/src/recipe-step-contract.js +164 -0
  47. package/src/recipe-step-contract.json +65 -0
  48. package/src/reference-help.js +182 -79
  49. package/src/session.js +39 -24
  50. package/src/setting-reference.js +239 -48
  51. package/src/settings-catalog.js +63 -0
  52. package/src/site-check-findings.js +23 -5
  53. package/src/site-check-rules.json +1 -0
  54. package/src/site-health-findings.js +13 -13
  55. package/src/styling-fixed-values.js +71 -0
  56. package/src/tag-destination-warnings.js +35 -0
  57. package/src/template-token-reach.json +242 -0
  58. package/src/theme-proposals.js +18 -27
  59. package/src/theme-resolve.js +265 -23
  60. package/src/theme-validation.js +118 -7
  61. package/src/token-reach.js +222 -0
  62. package/src/typed-page-reference.js +94 -16
  63. package/src/typed-pages.js +233 -74
  64. package/src/verbs/authors.js +198 -33
  65. package/src/verbs/deploy.js +6 -0
  66. package/src/verbs/footer-push.js +30 -5
  67. package/src/verbs/forms-push.js +11 -3
  68. package/src/verbs/index.js +4 -2
  69. package/src/verbs/pages-delete.js +19 -10
  70. package/src/verbs/pages-push.js +225 -71
  71. package/src/verbs/plan.js +10 -4
  72. package/src/verbs/pull.js +324 -69
  73. package/src/verbs/staging-review.js +27 -1
  74. package/src/verbs/status.js +22 -0
  75. package/src/verbs/theme-push.js +93 -25
  76. package/src/verbs/theme-resolve.js +189 -55
  77. package/src/verbs/validate.js +6 -5
  78. package/src/workspace-check.js +35 -3
  79. package/src/workspace.js +73 -2
  80. package/test/fixtures/default-site-theme.json +516 -0
@@ -1,4 +1,18 @@
1
+ import { readFileSync } from "node:fs";
2
+
1
3
  import { APPEARANCE_SCALAR_FIELDS } from "./appearance-contract.js";
4
+ import { BLOCK_SPACINGS, HEADING_SPACING_FIELDS } from "./block-flow.js";
5
+ import { RECIPE_TAGS_BAR_COLOR_TOKENS } from "./brand-color.js";
6
+ import { CONTENT_INSET_OPTIONS, CONTENT_WELL_MAX_REM, contentInsetPixels } from "./content-inset.js";
7
+ import { projectFooterSettingsForWorkspace } from "./footer-contract.js";
8
+ import {
9
+ DEFAULT_RECIPE_JUMP_CONTROL,
10
+ DEFAULT_RECIPE_TAGS_ICON,
11
+ DEFAULT_RECIPE_TAGS_CONTENT,
12
+ RECIPE_TAGS_CONTENT,
13
+ RECIPE_JUMP_CONTROLS,
14
+ RECIPE_TAGS_ICONS,
15
+ } from "./recipe-page-options.js";
2
16
  import {
3
17
  SETTINGS_GROUPS,
4
18
  SETTINGS_TYPE_BRAND,
@@ -6,6 +20,7 @@ import {
6
20
  SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
7
21
  SETTINGS_TYPE_TAPROOT_STYLES,
8
22
  } from "./settings-catalog.js";
23
+ import { projectPulledTheme } from "./theme-projection.js";
9
24
 
10
25
  /**
11
26
  * What every setting the CLI pulls means, which app control it is, and where it
@@ -21,16 +36,64 @@ import {
21
36
  const BRAND = "Brand & style > Brand";
22
37
  const HEADER = "Header & navigation";
23
38
  const FEATURES = "Features";
39
+ const RECIPE_TAG_BAR_COLOR_USAGE = "Use a hex or bounded oklch color, or one of " + [...RECIPE_TAGS_BAR_COLOR_TOKENS].join(", ") + ".";
24
40
 
25
41
  function entry(appLabel, description, renders, defaultValue) {
26
42
  return Object.freeze({
27
43
  appLabel,
28
44
  description,
29
- ...(renders === undefined ? {} : { renders }),
45
+ renders,
30
46
  ...(defaultValue === undefined ? {} : { default: defaultValue }),
31
47
  });
32
48
  }
33
49
 
50
+ function readOnlyEntry(appLabel, sourceField, renders) {
51
+ return Object.freeze({
52
+ ...entry(
53
+ appLabel,
54
+ `The delivery URL projected from ${sourceField}.`,
55
+ `${renders} The server fills this read-only URL when the image is ready.`,
56
+ ),
57
+ noDefault: true,
58
+ });
59
+ }
60
+
61
+ const HEADING_BEFORE_DEFAULT = Object.freeze({
62
+ headingStart: "--esp-size-small-to-normal",
63
+ blockSpacing: Object.freeze({ ...BLOCK_SPACINGS }),
64
+ where: "Taproot scales the heading’s start margin for direct h1–h5 children in section content, columns, body and "
65
+ + "introduction slots, recipe stories and legal bodies. The first child of a column, a compact-following "
66
+ + "section or a legal body has zero start margin. A heading after an image banner also has zero start margin.",
67
+ source: "Taproot block flow and blockSpacing",
68
+ });
69
+
70
+ const HEADING_AFTER_DEFAULT = Object.freeze({
71
+ headingEnd: "--esp-size-tiny-to-small",
72
+ paragraphStart: "--esp-type-normal",
73
+ where: "Multiply the following ordinary paragraph’s start margin by blockSpacing. The collapsed gap is the "
74
+ + "larger of that margin and the heading’s end margin.",
75
+ source: "Taproot block flow and esp-root heading margins",
76
+ });
77
+
78
+ function headingSpacingEntry(name) {
79
+ const before = name.endsWith("Before");
80
+ const side = before ? "above" : "below";
81
+ const level = name["headingH".length];
82
+ const titleGap = name === "headingH1SpaceAfter"
83
+ ? " Also sets the gap from article, album, recipe and place review titles to the first metadata row. Empty uses the header gap scaled by Block spacing."
84
+ : "";
85
+ return Object.freeze({
86
+ ...entry(
87
+ `${BRAND} > Heading spacing > Heading ${level} space ${side} (Standard sites only)`,
88
+ `Exact gap ${side} a level ${level} heading in rem. Use a canonical string such as "0" or "2.5". Empty follows Block spacing.`,
89
+ "Between authored headings and eligible in-flow siblings in both color schemes. Published spacing follows the "
90
+ + "rendered heading level. Page preview uses the authored level. Select Taproot styles for the next stage or deploy."
91
+ + titleGap,
92
+ ),
93
+ defaultRendering: before ? HEADING_BEFORE_DEFAULT : HEADING_AFTER_DEFAULT,
94
+ });
95
+ }
96
+
34
97
  /** Both schemes' image fields share a sentence shape. */
35
98
  const LOGO_RENDERS = "The brand slot of the header, at the height brandLogoSize sets, and the footer's brand once the "
36
99
  + "footer is enabled with its brand on. On a standard site a scheme with no logo of its own uses the other "
@@ -44,11 +107,21 @@ const CANVAS_RENDERS = "Only the empty side margins of a page, the left and righ
44
107
  + "shell, never behind the content. The browser's default background rules apply, so the image tiles at its natural "
45
108
  + "pixel size from the top-left of each margin; nothing resizes it to the margin, and the file delivered is the "
46
109
  + "largest rendition (a WebP up to 2000 px wide). A standard site's pages have margins 0 px wide at every "
47
- + "viewport, so the image does not appear on one today.";
110
+ + "viewport, so the canvas image does not appear on Standard sites. Use pageBackgroundImage to paint behind "
111
+ + "the main content.";
48
112
 
49
113
  const OPACITY_RENDERS = "Sets the opacity of the canvas image layer in the same side margins; it applies only while a "
50
114
  + "canvas image is set.";
51
115
 
116
+ const COMPACT_LOGO_RENDERS =
117
+ "When the header starts shrinking: this scheme's ready compact logo, then the other compact scheme, then the regular logo. "
118
+ + "Pending or failed compact artwork keeps the regular logo.";
119
+
120
+ const FAVICON_RENDERS =
121
+ "Linked from the head of every published page as favicon.ico, square PNGs from 16 to 512 px and a 180 px Apple "
122
+ + "touch icon. A site with no favicon still serves /favicon.ico: a neutral mark on a standard site, the Taproot mark on a "
123
+ + "profile site. Use a simplified square mark with a readable silhouette.";
124
+
52
125
  /** The page background image's rendering, stated once for the theme reference, `help settings` and the README. */
53
126
  export const PAGE_BACKGROUND_IMAGE_RENDERING =
54
127
  "One layer across the whole page box, behind the content. The header and "
@@ -62,7 +135,7 @@ export const PAGE_BACKGROUND_VERSUS_CANVAS = Object.freeze({
62
135
  + "field for it.",
63
136
  canvas:
64
137
  "Page canvas > Canvas image is lightCanvasImageId and darkCanvasImageId in settings/taproot-styles.json, with "
65
- + "their opacity fields. It paints only the side margins outside the page content.",
138
+ + "their opacity fields. " + CANVAS_RENDERS,
66
139
  shared:
67
140
  "Neither sets a size, repeat or position, so both tile at the image's natural pixel size from the top-left. The "
68
141
  + "published site copies the file the URL names into its own assets; it does not resize it.",
@@ -93,47 +166,78 @@ const TAPROOT_STYLES_ENTRIES = {
93
166
  + "happens when any settings group or navigation is selected for a stage or deploy. Pages copied forward from "
94
167
  + "an earlier deploy keep their old spacing until then.",
95
168
  ),
169
+ ...Object.fromEntries(HEADING_SPACING_FIELDS.map(name => [name, headingSpacingEntry(name)])),
170
+ contentInset: entry(
171
+ `${BRAND} > Content inset`,
172
+ "The space between the content and the sides of the page. The light theme's spacing scale sets the inset for both color schemes.",
173
+ "Padded free-form bands, structured pages, breadcrumbs, the contained header and the footer share a "
174
+ + `${CONTENT_WELL_MAX_REM}rem well. Wide and centered-brand headers, unpadded bands and surfaced box padding `
175
+ + "keep their own spacing. The managed Docs content grid keeps its own inset. Root and unpadded unsurfaced banner copy aligns with the page. On a Standard site, "
176
+ + "include Taproot styles in the next whole-site deployment.",
177
+ ),
178
+ breadcrumbSeparator: entry(
179
+ `${BRAND} > Breadcrumb separator (Standard sites only)`,
180
+ "The mark between folder crumbs. Use arrow-filled (default), chevron, line-arrow, slash, or none.",
181
+ "Between folder crumbs on published Standard sites when a page has at least two folder ancestors. Applies in both color schemes.",
182
+ ),
183
+ breadcrumbTrailEnd: entry(
184
+ `${BRAND} > Trail end (Standard sites only)`,
185
+ "The mark after the last crumb. Use arrow-down-filled (default), same as the selected separator, or none.",
186
+ "After the last folder crumb on published Standard sites, in both color schemes.",
187
+ ),
188
+ breadcrumbSeparatorArtwork: entry(
189
+ "Breadcrumb artwork (CLI)",
190
+ "A workspace SVG file reference {file, color} or the geometry returned by pull. It replaces the between-crumb preset when present. Empty restores the preset.",
191
+ "Between folder crumbs on Standard sites, and after the last crumb when trail end is same.",
192
+ ),
193
+ breadcrumbTrailEndArtwork: entry(
194
+ "Breadcrumb trail end artwork (CLI)",
195
+ "A separate workspace SVG file reference {file, color} or the geometry returned by pull. Empty restores the trail end preset.",
196
+ "After the last folder crumb on Standard sites, in both color schemes.",
197
+ ),
96
198
  lightLogoId: entry(
97
199
  `${BRAND} > Logo`,
98
200
  "The site-owned image used as the brand logo in the light scheme.",
99
201
  LOGO_RENDERS,
100
202
  ),
101
- lightLogoUrl: entry(`${BRAND} > Logo`, "Read-only: the delivery URL of lightLogoId."),
203
+ lightLogoUrl: readOnlyEntry(`${BRAND} > Logo`, "lightLogoId", LOGO_RENDERS),
102
204
  darkLogoId: entry(
103
205
  `${BRAND} > Logo`,
104
206
  "The site-owned image used as the brand logo in the dark scheme.",
105
207
  LOGO_RENDERS,
106
208
  ),
107
- darkLogoUrl: entry(`${BRAND} > Logo`, "Read-only: the delivery URL of darkLogoId."),
209
+ darkLogoUrl: readOnlyEntry(`${BRAND} > Logo`, "darkLogoId", LOGO_RENDERS),
108
210
  lightCompactLogoId: entry(
109
211
  `${HEADER} > Compact logo`,
110
212
  "Optional site-owned light-scheme logo for a Fixed header above 1.0. Hidden controls retain saved choices.",
111
- "When the header starts shrinking: this scheme's ready compact logo, then the other compact scheme, then the regular logo. Pending or failed compact artwork keeps the regular logo.",
213
+ COMPACT_LOGO_RENDERS,
112
214
  ),
113
- lightCompactLogoUrl: entry(`${HEADER} > Compact logo`, "Read-only: the delivery URL of lightCompactLogoId."),
215
+ lightCompactLogoUrl: readOnlyEntry(`${HEADER} > Compact logo`, "lightCompactLogoId", COMPACT_LOGO_RENDERS),
114
216
  darkCompactLogoId: entry(
115
217
  `${HEADER} > Compact logo`,
116
218
  "Optional site-owned dark-scheme logo for a Fixed header above 1.0. Hidden controls retain saved choices.",
117
- "When the header starts shrinking: this scheme's ready compact logo, then the other compact scheme, then the regular logo. Pending or failed compact artwork keeps the regular logo.",
219
+ COMPACT_LOGO_RENDERS,
118
220
  ),
119
- darkCompactLogoUrl: entry(`${HEADER} > Compact logo`, "Read-only: the delivery URL of darkCompactLogoId."),
221
+ darkCompactLogoUrl: readOnlyEntry(`${HEADER} > Compact logo`, "darkCompactLogoId", COMPACT_LOGO_RENDERS),
120
222
  lightCanvasImageId: entry(
121
223
  "Brand & style > Page canvas > Canvas image",
122
224
  "The site-owned image painted in the side margins of a page in the light scheme.",
123
225
  CANVAS_RENDERS,
124
226
  ),
125
- lightCanvasImageUrl: entry(
227
+ lightCanvasImageUrl: readOnlyEntry(
126
228
  "Brand & style > Page canvas > Canvas image",
127
- "Read-only: the delivery URL of lightCanvasImageId.",
229
+ "lightCanvasImageId",
230
+ CANVAS_RENDERS,
128
231
  ),
129
232
  darkCanvasImageId: entry(
130
233
  "Brand & style > Page canvas > Canvas image",
131
234
  "The site-owned image painted in the side margins of a page in the dark scheme.",
132
235
  CANVAS_RENDERS,
133
236
  ),
134
- darkCanvasImageUrl: entry(
237
+ darkCanvasImageUrl: readOnlyEntry(
135
238
  "Brand & style > Page canvas > Canvas image",
136
- "Read-only: the delivery URL of darkCanvasImageId.",
239
+ "darkCanvasImageId",
240
+ CANVAS_RENDERS,
137
241
  ),
138
242
  lightCanvasImageOpacity: entry(
139
243
  "Brand & style > Page canvas > Canvas image",
@@ -151,12 +255,13 @@ const BRAND_ENTRIES = {
151
255
  faviconId: entry(
152
256
  `${BRAND} > Favicon`,
153
257
  "The square site-owned image the platform turns into the site's icon set.",
154
- "Linked from the head of every published page as favicon.ico, square PNGs from 16 to 512 px and a 180 px Apple "
155
- + "touch icon. A site with no favicon still serves /favicon.ico: a neutral mark on a standard site, the Taproot mark on a "
156
- + "profile site. Use a simplified square mark, not a "
157
- + "full wordmark.",
258
+ FAVICON_RENDERS,
259
+ ),
260
+ faviconUrl: readOnlyEntry(
261
+ `${BRAND} > Favicon`,
262
+ "faviconId",
263
+ "Supplies the single icon link in the published page head when the generated icon set is unavailable.",
158
264
  ),
159
- faviconUrl: entry(`${BRAND} > Favicon`, "Read-only: the delivery URL of faviconId."),
160
265
  };
161
266
 
162
267
  const HEADER_ENTRIES = {
@@ -164,13 +269,11 @@ const HEADER_ENTRIES = {
164
269
  `${HEADER} > Logo`,
165
270
  "Which artwork the header uses: empty matches the color scheme, light chooses light-background artwork, and dark chooses dark-background artwork.",
166
271
  "The header's regular and eligible compact logos; footer and legal PDF choices remain independent.",
167
- "",
168
272
  ),
169
273
  context: entry(
170
274
  `${HEADER} > Colors`,
171
275
  "The header's theme context, declared by both schemes; empty uses the page colors.",
172
276
  "Everything in the header, including navigation and its drawer.",
173
- "",
174
277
  ),
175
278
  headerLayout: entry(
176
279
  `${HEADER} > Layout`,
@@ -371,12 +474,64 @@ const PREFERENCES_ENTRIES = {
371
474
  "Album pages.",
372
475
  90,
373
476
  ),
477
+ recipeJumpControl: entry(
478
+ `${FEATURES} > Recipe pages > Show "Jump to recipe"`,
479
+ `Choose ${RECIPE_JUMP_CONTROLS.join(", ")}. An empty value resets this setting to ${DEFAULT_RECIPE_JUMP_CONTROL}.`,
480
+ "In the byline after the date on public recipe pages. The link or compact button leads to #recipe. Applies after deployment.",
481
+ ),
482
+ recipeTagsIcon: entry(
483
+ `${FEATURES} > Recipe pages > Tag icon`,
484
+ `Choose ${RECIPE_TAGS_ICONS.join(", ")}. An empty value resets this setting to ${DEFAULT_RECIPE_TAGS_ICON}.`,
485
+ "Beside the recipe card's tags. Choose none to show the tags on their own. Applies after deployment.",
486
+ ),
487
+ recipeTagsContent: entry(
488
+ `${FEATURES} > Recipe pages > Recipe tag bar contents`,
489
+ `Choose ${RECIPE_TAGS_CONTENT.join(", ")}. The default is ${DEFAULT_RECIPE_TAGS_CONTENT} and applies independently of pageTagBadges. `
490
+ + "Both shows authored tags first and adds category, cuisine and method once each, ignoring case. "
491
+ + "A shared name retains its authored badge and link. Set tagDestinations for that label.",
492
+ "At the card's bottom on published recipes. An empty bar is omitted. Category, cuisine and method still appear in structured data.",
493
+ ),
494
+ recipeMetadataDestinations: entry(
495
+ "Recipe metadata destinations",
496
+ 'Map metadata values to page resource IDs from pull, for example {"Soup":"<resourceId>"}. Values normalize to slugs. '
497
+ + "A mapping overrides a matching site tag's destination for metadata badges. Without a map entry, a matching site tag provides its destination, even if unassigned. "
498
+ + "Use {} to clear the map or omit it to preserve it. Save with theme push using Design permission (site.theme.manage).",
499
+ "Metadata badges link when the destination is public and stays on the site. A missing destination leaves the badge plain.",
500
+ ),
501
+ recipeTagsBarBackground: entry(
502
+ "Recipe tag bar fill",
503
+ RECIPE_TAG_BAR_COLOR_USAGE + " Empty uses --esp-color-layer-3. Theme colors follow the scheme.",
504
+ "The card's full-width bottom tag bar.",
505
+ ),
506
+ recipeTagsBarBorderColor: entry(
507
+ "Recipe tag bar border",
508
+ RECIPE_TAG_BAR_COLOR_USAGE + " Empty uses --esp-color-border.",
509
+ "The dotted line at the top of the recipe card tag bar.",
510
+ ),
511
+ recipeTagsBarColor: entry(
512
+ "Recipe tag bar ink",
513
+ RECIPE_TAG_BAR_COLOR_USAGE + " Empty uses --esp-color-text. Validation warns below 3:1 against the bar fill in either color scheme. Set badge ink in help theme.",
514
+ "The recipe tag bar's decorative icon.",
515
+ ),
516
+ tagDestinations: entry(
517
+ "Tag destinations",
518
+ "Map authored tag names to page resource IDs from pull. Names are case-insensitive and pull writes canonical slugs. "
519
+ + "Use an existing site tag, even if it is not assigned to any page yet. Use {} to clear the map or omit the field to preserve it. "
520
+ + "Save with theme push (Design permission, site.theme.manage). Validate and preview with theme push --dry-run.",
521
+ "Published authored badges link to the destination's current public path. A missing, draft or members-only destination leaves "
522
+ + "the badge plain. Matching values can also use the destination in a recipe tag bar. See help appearance.",
523
+ ),
524
+ pageTagBadges: entry(
525
+ "Settings > Features > Tag badges",
526
+ "Choose none, page or page-and-cards for headers and listing cards. Defaults to none. Recipe tag bars follow recipeTagsContent independently.",
527
+ "Standard-site article, recipe, album and place review headers. Page-and-cards also adds badges to folder and Latest Posts cards. "
528
+ + "Badges sort alphabetically, ignoring case.",
529
+ ),
374
530
  footerSettings: entry(
375
531
  "Footer",
376
532
  "The whole footer: link columns, aside and bottom text, brand, feature image, theme context and per-scheme background art.",
377
533
  "The footer of every published page, but only once footerSettings.enabled is true. help footer has the closed "
378
534
  + "schema.",
379
- { enabled: false },
380
535
  ),
381
536
  };
382
537
 
@@ -387,20 +542,43 @@ export const SETTING_FIELD_REFERENCE = Object.freeze({
387
542
  [SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES]: Object.freeze(PREFERENCES_ENTRIES),
388
543
  });
389
544
 
545
+ const SCALARS_BY_KEY = new Map(
546
+ APPEARANCE_SCALAR_FIELDS.map((field) => [`${field.settingsType}:${field.name}`, field]),
547
+ );
548
+ const THEME_SCHEMES = new Map([["lightTheme", "light"], ["darkTheme", "dark"]]);
549
+ let seededThemeArtifact;
550
+
390
551
  /** The description, app control and rendering note for one catalog field, for the references that list it. */
391
552
  export function describeSettingField(settingsType, name) {
392
553
  const known = SETTING_FIELD_REFERENCE[settingsType]?.[name];
393
554
  if (known === undefined) throw new TypeError(`No setting reference for ${settingsType} ${name}.`);
555
+ const scalar = SCALARS_BY_KEY.get(`${settingsType}:${name}`);
556
+ if (scalar?.name === "contentInset") {
557
+ const viewportWidths = [375, 1280];
558
+ return {
559
+ ...known,
560
+ default: scalar.default,
561
+ referenceRootPixels: 16,
562
+ viewportWidths,
563
+ sizes: CONTENT_INSET_OPTIONS.map(value => ({
564
+ value,
565
+ pixels: viewportWidths.map(width => Number(contentInsetPixels("", value, width).toFixed(2))),
566
+ })),
567
+ };
568
+ }
569
+ if (scalar) return { ...known, default: scalar.default };
570
+ const scheme = THEME_SCHEMES.get(name);
571
+ if (scheme) {
572
+ seededThemeArtifact ??= JSON.parse(readFileSync(new URL("../test/fixtures/default-site-theme.json", import.meta.url), "utf8"));
573
+ return { ...known, default: projectPulledTheme(seededThemeArtifact[scheme].theme, scheme) };
574
+ }
575
+ if (name === "footerSettings") return { ...known, default: projectFooterSettingsForWorkspace({}) };
394
576
  return known;
395
577
  }
396
578
 
397
- const WRITABLE_SCALARS = new Set(
398
- APPEARANCE_SCALAR_FIELDS.map((field) => `${field.settingsType}:${field.name}`),
399
- );
400
-
401
579
  /** How the CLI changes a field: the verb that writes it, or that it is read-only here. */
402
580
  function writeVerb(group, field) {
403
- if (field.wireType === "theme" || WRITABLE_SCALARS.has(`${group.settingsType}:${field.name}`)) return "theme push";
581
+ if (field.wireType === "theme" || SCALARS_BY_KEY.has(`${group.settingsType}:${field.name}`)) return "theme push";
404
582
  if (field.name === "footerSettings") {
405
583
  return "footer push (content); theme push (context and logoVariant)";
406
584
  }
@@ -451,29 +629,18 @@ export const THEME_CONTROLS = Object.freeze([
451
629
 
452
630
  /** The reference `help settings` prints: every catalog field with its meaning, app control and write path. */
453
631
  export function getSettingsReference() {
454
- const scalarDefaults = new Map(
455
- APPEARANCE_SCALAR_FIELDS.map((field) => [`${field.settingsType}:${field.name}`, field.default]),
456
- );
457
632
  return {
458
633
  title: "Site settings: what each field is, which app control it is, and where it renders",
459
634
  referenceKind: "settings",
460
635
  usage: "pull | theme push | footer push",
461
636
  groups: SETTINGS_GROUPS.map((group) => ({
462
637
  file: `settings/${group.file}`,
463
- fields: group.fields.map((field) => {
464
- const known = SETTING_FIELD_REFERENCE[group.settingsType][field.name];
465
- const scalarKey = `${group.settingsType}:${field.name}`;
466
- const defaultValue = scalarDefaults.has(scalarKey) ? scalarDefaults.get(scalarKey) : known.default;
467
- return {
468
- path: `settings.${field.name}`,
469
- wireType: field.wireType,
470
- appLabel: known.appLabel,
471
- description: known.description,
472
- ...(defaultValue === undefined ? {} : { default: defaultValue }),
473
- ...(known.renders === undefined ? {} : { renders: known.renders }),
474
- write: writeVerb(group, field),
475
- };
476
- }),
638
+ fields: group.fields.map((field) => ({
639
+ path: `settings.${field.name}`,
640
+ wireType: field.wireType,
641
+ ...describeSettingField(group.settingsType, field.name),
642
+ write: writeVerb(group, field),
643
+ })),
477
644
  })),
478
645
  themeControls: THEME_CONTROLS.map((control) => ({
479
646
  ...control,
@@ -484,15 +651,39 @@ export function getSettingsReference() {
484
651
  };
485
652
  }
486
653
 
654
+ export function formatReferenceDefault(field) {
655
+ if (field.noDefault) return "no default";
656
+ if (!Object.hasOwn(field, "default")) return "";
657
+ const scheme = THEME_SCHEMES.get(field.path?.slice("settings.".length));
658
+ return scheme
659
+ ? `default seeded ${scheme} theme (see --json for the complete value)`
660
+ : `default ${JSON.stringify(field.default)}`;
661
+ }
662
+
663
+ export function formatDefaultRendering({ defaultRendering }) {
664
+ if (defaultRendering === undefined) return "";
665
+ const { where, source, ...values } = defaultRendering;
666
+ const tokens = Object.entries(values).map(([name, value]) =>
667
+ `${name} ${typeof value === "string" ? value : JSON.stringify(value)}`
668
+ );
669
+ return `Default rendering when empty — ${tokens.join(", ")}. ${where} From ${source}.`;
670
+ }
671
+
672
+ export function formatSettingSizes(field) {
673
+ if (!field.sizes) return "";
674
+ const widths = field.viewportWidths.map(width => `${width}px`).join(" and ");
675
+ const options = field.sizes.map(({ value, pixels }) => `${value} ${pixels.join(" / ")}px`).join(", ");
676
+ return `\n Default theme at ${widths} (with a ${field.referenceRootPixels}px root): ${options}.`;
677
+ }
678
+
487
679
  export function formatSettingsReference(reference) {
488
680
  const groups = reference.groups.map((group) =>
489
681
  `${group.file}\n${
490
682
  group.fields.map((field) =>
491
- ` ${field.path} (${field.wireType}; ${field.write}${
492
- field.default === undefined ? "" : `; default ${JSON.stringify(field.default)}`
493
- })\n app: ${field.appLabel}\n ${field.description}${
494
- field.renders === undefined ? "" : `\n renders: ${field.renders}`
495
- }`
683
+ ` ${field.path} (${field.wireType}; ${field.write}; ${formatReferenceDefault(field)})\n`
684
+ + ` app: ${field.appLabel}\n ${field.description}\n renders: ${field.renders}`
685
+ + (field.defaultRendering === undefined ? "" : `\n ${formatDefaultRendering(field)}`)
686
+ + formatSettingSizes(field)
496
687
  ).join("\n")
497
688
  }`
498
689
  ).join("\n\n");
@@ -1,8 +1,15 @@
1
1
  import { parseTheme } from "@taprootio/espalier/shared/theme";
2
2
 
3
+ import { HEADING_SPACING_FIELDS, normalizeHeadingSpacing } from "./block-flow.js";
4
+ import { BREADCRUMB_ARTWORK_FIELDS, decodeBreadcrumbArtwork } from "./breadcrumb-artwork.js";
5
+ import { normalizeBreadcrumbSeparator, normalizeBreadcrumbTrailEnd } from "./breadcrumb-separators.js";
6
+ import { normalizeContentInset } from "./content-inset.js";
3
7
  import { SiteAuthoringError } from "./errors.js";
8
+ import { closeFieldMatch, unknownFieldHint } from "./field-suggestions.js";
4
9
  import { projectFooterSettingsForWorkspace } from "./footer-contract.js";
5
10
  import { parseHeaderHeightMultiplier, resolveLogoVariant } from "./header-presentation.js";
11
+ import { normalizePageTagBadges } from "./page-tag-badge-modes.js";
12
+ import { normalizeRecipeJumpControl, normalizeRecipeTagsContent, normalizeRecipeTagsIcon } from "./recipe-page-options.js";
6
13
  import { projectPulledTheme } from "./theme-projection.js";
7
14
 
8
15
  /**
@@ -73,6 +80,22 @@ export const SETTINGS_GROUPS = Object.freeze([
73
80
  "darkCanvasImageId",
74
81
  "darkCanvasImageUrl",
75
82
  ),
83
+ ...HEADING_SPACING_FIELDS.map(name => ({ name, wireType: "string", normalize: normalizeHeadingSpacing })),
84
+ { name: "contentInset", wireType: "string", normalize: normalizeContentInset },
85
+ { name: "breadcrumbSeparator", wireType: "string", normalize: normalizeBreadcrumbSeparator },
86
+ { name: "breadcrumbTrailEnd", wireType: "string", normalize: normalizeBreadcrumbTrailEnd },
87
+ ...BREADCRUMB_ARTWORK_FIELDS.map(name => ({
88
+ name,
89
+ wireType: "string",
90
+ normalize(value) {
91
+ if (value === undefined || value === null || value === "") return "";
92
+ const artwork = decodeBreadcrumbArtwork(value);
93
+ if (artwork === undefined) {
94
+ throw new SiteAuthoringError("api.setting_contract", "Taproot returned invalid breadcrumb artwork.", { field: name });
95
+ }
96
+ return artwork;
97
+ },
98
+ })),
76
99
  { name: "lightCanvasImageOpacity", wireType: "double" },
77
100
  { name: "darkCanvasImageOpacity", wireType: "double" },
78
101
  ]),
@@ -149,6 +172,15 @@ export const SETTINGS_GROUPS = Object.freeze([
149
172
  { name: "albumBorderWidth", wireType: "int" },
150
173
  { name: "albumMaxImagesPerRow", wireType: "int" },
151
174
  { name: "albumMaxRowHeightVh", wireType: "int" },
175
+ { name: "recipeJumpControl", wireType: "string", normalize: normalizeRecipeJumpControl },
176
+ { name: "recipeTagsIcon", wireType: "string", normalize: normalizeRecipeTagsIcon },
177
+ { name: "pageTagBadges", wireType: "string", normalize: normalizePageTagBadges },
178
+ { name: "tagDestinations", wireType: "document", optional: true },
179
+ { name: "recipeTagsContent", wireType: "string", normalize: normalizeRecipeTagsContent, optional: true },
180
+ { name: "recipeMetadataDestinations", wireType: "document", optional: true },
181
+ { name: "recipeTagsBarBackground", wireType: "string", optional: true },
182
+ { name: "recipeTagsBarBorderColor", wireType: "string", optional: true },
183
+ { name: "recipeTagsBarColor", wireType: "string", optional: true },
152
184
  { name: "footerSettings", wireType: "document", zero: {} },
153
185
  ]),
154
186
  }),
@@ -166,6 +198,7 @@ function zeroValue(field) {
166
198
  }
167
199
 
168
200
  function normalizeField(field, value) {
201
+ if (field.normalize) return field.normalize(value);
169
202
  if (value === undefined || value === null) {
170
203
  const zero = zeroValue(field);
171
204
  return field.wireType === "document" && field.name === "footerSettings"
@@ -227,6 +260,7 @@ export function projectSettingsGroup(group, response) {
227
260
  if (height.canonical !== "") projected[field.name] = height.canonical;
228
261
  continue;
229
262
  }
263
+ if (field.optional && source[field.name] === undefined) continue;
230
264
  projected[field.name] = normalizeField(field, source[field.name]);
231
265
  if (field.wireType === "theme") {
232
266
  // A stored theme is what was written, possibly before a required key
@@ -241,3 +275,32 @@ export function projectSettingsGroup(group, response) {
241
275
  }
242
276
  return projected;
243
277
  }
278
+
279
+ /** Validate against the pull projection, including fields that only the server writes. */
280
+ export function requireKnownAppearanceSettings(documents) {
281
+ const problems = [];
282
+ let alternatives;
283
+ for (const group of SETTINGS_GROUPS) {
284
+ const type = group.settingsType;
285
+ if (type !== SETTINGS_TYPE_TAPROOT_STYLES && type !== SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES) continue;
286
+ const names = group.fields.map(({ name }) => name);
287
+ const helpTopic = type === SETTINGS_TYPE_TAPROOT_STYLES ? "appearance" : "settings";
288
+ for (const key of Object.keys(documents[type])) {
289
+ if (names.includes(key)) continue;
290
+ const nearest = closeFieldMatch(key, names);
291
+ const field = group.file.slice(0, -".json".length) + "." + key;
292
+ if (problems.length === 0 && nearest !== undefined) alternatives = [nearest];
293
+ problems.push({
294
+ code: "theme.setting_unknown",
295
+ file: "settings/" + group.file,
296
+ field,
297
+ message: `Unknown setting '${field}'.${unknownFieldHint(nearest, helpTopic)}`,
298
+ });
299
+ }
300
+ }
301
+ if (problems.length === 0) return;
302
+ const first = problems[0];
303
+ throw new SiteAuthoringError(first.code, first.message, {
304
+ field: first.field, alternatives,
305
+ }).withProblems(problems);
306
+ }
@@ -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" },