@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.
- package/README.md +32 -1
- 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 +161 -8
- package/src/appearance-contract.js +264 -3
- package/src/authored-tag-names.js +88 -0
- package/src/block-flow.js +103 -1
- package/src/brand-color.js +22 -0
- package/src/breadcrumb-artwork.js +234 -0
- package/src/breadcrumb-separators.js +11 -0
- package/src/changelog.json +143 -0
- package/src/chrome-features.js +6 -2
- package/src/chrome-input.js +1 -0
- package/src/chrome-paint-catalog-taproot.json +3 -3
- package/src/chrome-report.js +91 -12
- package/src/cli.js +45 -16
- package/src/content/components.js +27 -4
- package/src/content/external-link.js +2 -1
- package/src/content/markdown.js +271 -101
- package/src/content/tiptap-prosemirror.ts +125 -43
- package/src/content/validate-document.js +4 -1
- package/src/content-inset.js +48 -0
- package/src/errors.js +1 -0
- package/src/espalier-shared.js +26 -0
- package/src/field-suggestions.js +40 -0
- package/src/fixture-init.js +22 -5
- package/src/font-catalog.js +11 -1
- package/src/footer-brand-inputs.js +22 -3
- package/src/footer-content.js +1 -0
- package/src/footer-contract.js +11 -0
- package/src/footer-cta-styles.js +6 -0
- package/src/footer-draft-hash.js +4 -2
- package/src/footer-fit.js +62 -15
- package/src/footer-workspace.js +44 -7
- package/src/latest-posts-tags.js +57 -0
- package/src/page-structure-checks.js +5 -0
- package/src/page-tag-badge-modes.js +6 -0
- package/src/page-tag-writes.js +158 -0
- package/src/page-type-tags.js +16 -0
- package/src/presentation-reference.js +297 -86
- package/src/recipe-page-options.js +22 -0
- package/src/recipe-step-contract.js +164 -0
- package/src/recipe-step-contract.json +65 -0
- package/src/reference-help.js +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 +23 -5
- package/src/site-check-rules.json +1 -0
- package/src/site-health-findings.js +13 -13
- package/src/styling-fixed-values.js +71 -0
- package/src/tag-destination-warnings.js +35 -0
- package/src/template-token-reach.json +242 -0
- package/src/theme-proposals.js +18 -27
- package/src/theme-resolve.js +265 -23
- package/src/theme-validation.js +118 -7
- package/src/token-reach.js +222 -0
- package/src/typed-page-reference.js +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 +93 -25
- package/src/verbs/theme-resolve.js +189 -55
- package/src/verbs/validate.js +6 -5
- package/src/workspace-check.js +35 -3
- package/src/workspace.js +37 -1
- package/test/fixtures/default-site-theme.json +516 -0
package/src/session.js
CHANGED
|
@@ -220,7 +220,16 @@ export async function resolveApiBaseUrl(environment) {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
export async function openSession(invocation = {}) {
|
|
223
|
-
|
|
223
|
+
const resolved = await resolveSiteSession(invocation);
|
|
224
|
+
return await resolved.open();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Resolves the credential and bound site locally before a verb needs to use either on the wire. */
|
|
228
|
+
export async function resolveSiteSession(invocation = {}) {
|
|
229
|
+
if (invocation.resolvedSession !== undefined) {
|
|
230
|
+
const session = invocation.resolvedSession;
|
|
231
|
+
return { config: session.config, siteId: session.siteId, open: () => session };
|
|
232
|
+
}
|
|
224
233
|
const environment = invocation.environment ?? process.env;
|
|
225
234
|
const onProgress = progressSink(invocation);
|
|
226
235
|
const now = invocation.now ?? Date.now;
|
|
@@ -240,23 +249,7 @@ export async function openSession(invocation = {}) {
|
|
|
240
249
|
const config = await loadConfig(invocation);
|
|
241
250
|
if (!config.siteId) throw siteMissingError();
|
|
242
251
|
requireRecordedSurface(invocation, config);
|
|
243
|
-
|
|
244
|
-
?? new SiteApiClient(buildClientOptions(invocation, apiBaseUrl, environmentToken));
|
|
245
|
-
// No exchange happens on this path, and nothing else on the contract reads
|
|
246
|
-
// the platform switch — so its state is genuinely unknown here rather than
|
|
247
|
-
// assumed. Reporting it as enabled would be a guess, and reporting it as
|
|
248
|
-
// paused would warn on every write against a healthy platform.
|
|
249
|
-
return {
|
|
250
|
-
config,
|
|
251
|
-
client,
|
|
252
|
-
legalDrafts: false,
|
|
253
|
-
siteId: config.siteId,
|
|
254
|
-
surface: config.authoringSurface,
|
|
255
|
-
platform: UNKNOWN_PLATFORM,
|
|
256
|
-
release: UNKNOWN_CLI_RELEASE,
|
|
257
|
-
now,
|
|
258
|
-
onProgress,
|
|
259
|
-
};
|
|
252
|
+
return resolveDirectSiteSession(invocation, { config, apiBaseUrl, now, onProgress }, environmentToken);
|
|
260
253
|
}
|
|
261
254
|
|
|
262
255
|
if (invocation.legalDrafts) {
|
|
@@ -278,11 +271,7 @@ export async function openSession(invocation = {}) {
|
|
|
278
271
|
+ `If Taproot refuses it, run '${CLI_BINARY_NAME} ${VERB_LOGIN} --legal-drafts' again.`,
|
|
279
272
|
);
|
|
280
273
|
}
|
|
281
|
-
return {
|
|
282
|
-
config, client: invocation.client ?? new SiteApiClient(buildClientOptions(invocation, apiBaseUrl, credential.key)),
|
|
283
|
-
legalDrafts: true, siteId: config.siteId, surface: config.authoringSurface,
|
|
284
|
-
platform: UNKNOWN_PLATFORM, release: UNKNOWN_CLI_RELEASE, now, onProgress,
|
|
285
|
-
};
|
|
274
|
+
return resolveDirectSiteSession(invocation, { config, apiBaseUrl, now, onProgress }, credential.key);
|
|
286
275
|
}
|
|
287
276
|
|
|
288
277
|
let config;
|
|
@@ -295,6 +284,32 @@ export async function openSession(invocation = {}) {
|
|
|
295
284
|
if (!config.siteId) throw siteMissingError();
|
|
296
285
|
requireRecordedSurface(invocation, config);
|
|
297
286
|
|
|
287
|
+
return {
|
|
288
|
+
config,
|
|
289
|
+
siteId: config.siteId,
|
|
290
|
+
open: () => openStoredSiteSession(invocation, { environment, apiBaseUrl, config, signIn, now, onProgress }),
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function resolveDirectSiteSession(invocation, { config, apiBaseUrl, now, onProgress }, key) {
|
|
295
|
+
return {
|
|
296
|
+
config,
|
|
297
|
+
siteId: config.siteId,
|
|
298
|
+
open: () => ({
|
|
299
|
+
config,
|
|
300
|
+
client: invocation.client ?? new SiteApiClient(buildClientOptions(invocation, apiBaseUrl, key)),
|
|
301
|
+
legalDrafts: Boolean(invocation.legalDrafts),
|
|
302
|
+
siteId: config.siteId,
|
|
303
|
+
surface: config.authoringSurface,
|
|
304
|
+
platform: UNKNOWN_PLATFORM,
|
|
305
|
+
release: UNKNOWN_CLI_RELEASE,
|
|
306
|
+
now,
|
|
307
|
+
onProgress,
|
|
308
|
+
}),
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async function openStoredSiteSession(invocation, { environment, apiBaseUrl, config, signIn, now, onProgress }) {
|
|
298
313
|
// The server is the authority on expiry, so an expired sign-in is still sent
|
|
299
314
|
// — the clock here may simply be wrong. What is worth saying out loud is that
|
|
300
315
|
// the credential is already past the expiry it recorded, so a refusal that
|
|
@@ -324,7 +339,7 @@ export async function openSession(invocation = {}) {
|
|
|
324
339
|
|
|
325
340
|
const accountClient = new SiteApiClient(buildClientOptions(invocation, apiBaseUrl, signIn.key));
|
|
326
341
|
// Announced here, not left to the generic failure line. The exchange is the
|
|
327
|
-
// first request
|
|
342
|
+
// first network request a site verb makes and it sits outside each verb's own
|
|
328
343
|
// `withRefusalGuidance`, so a refusal raised by it used to reach the operator
|
|
329
344
|
// as a field name and nothing else. That matters most for `cli_outdated`,
|
|
330
345
|
// whose whole remedy is a command the operator has to be handed (TR00703),
|
package/src/setting-reference.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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.
|
|
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:
|
|
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:
|
|
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
|
-
|
|
213
|
+
COMPACT_LOGO_RENDERS,
|
|
112
214
|
),
|
|
113
|
-
lightCompactLogoUrl:
|
|
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
|
-
|
|
219
|
+
COMPACT_LOGO_RENDERS,
|
|
118
220
|
),
|
|
119
|
-
darkCompactLogoUrl:
|
|
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:
|
|
227
|
+
lightCanvasImageUrl: readOnlyEntry(
|
|
126
228
|
"Brand & style > Page canvas > Canvas image",
|
|
127
|
-
"
|
|
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:
|
|
237
|
+
darkCanvasImageUrl: readOnlyEntry(
|
|
135
238
|
"Brand & style > Page canvas > Canvas image",
|
|
136
|
-
"
|
|
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
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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" ||
|
|
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
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
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
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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");
|
package/src/settings-catalog.js
CHANGED
|
@@ -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
|
+
}
|