@taprootio/site-authoring 0.55.0 → 0.59.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 (65) hide show
  1. package/README.md +91 -22
  2. package/package.json +2 -2
  3. package/src/api.js +90 -17
  4. package/src/authors-contract.js +71 -3
  5. package/src/block-flow.js +4 -2
  6. package/src/changelog.json +104 -0
  7. package/src/chrome-additions.js +106 -0
  8. package/src/chrome-features.js +43 -10
  9. package/src/chrome-input.js +137 -30
  10. package/src/chrome-report.js +4 -2
  11. package/src/cli.js +144 -38
  12. package/src/constants.js +1 -0
  13. package/src/content/button-styles.js +27 -0
  14. package/src/content/components.js +76 -10
  15. package/src/content/free-form-section-registry.json +9 -0
  16. package/src/content/free-form-sections.js +55 -16
  17. package/src/content/markdown.js +133 -56
  18. package/src/content/media-presentation.js +37 -0
  19. package/src/content/tiptap-prosemirror.ts +26 -10
  20. package/src/credentials.js +2 -1
  21. package/src/delivery-check.js +10 -2
  22. package/src/font-catalog.js +9 -6
  23. package/src/footer-content.js +1 -1
  24. package/src/footer-contract.js +3 -0
  25. package/src/footer-draft-hash.js +1 -0
  26. package/src/heading-outline.js +94 -6
  27. package/src/image-description-contract.js +5 -3
  28. package/src/image-description-write.js +26 -0
  29. package/src/index.js +1 -0
  30. package/src/output.js +2 -1
  31. package/src/page-metadata.js +15 -13
  32. package/src/page-structure-checks.js +14 -25
  33. package/src/placed-image-ids.js +42 -17
  34. package/src/presentation-reference.js +63 -18
  35. package/src/problems.js +147 -4
  36. package/src/reference-help.js +122 -60
  37. package/src/site-check-findings.js +2 -3
  38. package/src/site-check-rules.json +0 -1
  39. package/src/site-health-findings.js +7 -9
  40. package/src/site-health-image-checks.js +4 -1
  41. package/src/site-health-precheck.js +23 -6
  42. package/src/site-navigation-groups.js +16 -0
  43. package/src/status-warning-paints.js +175 -0
  44. package/src/template-token-reach.json +13 -18
  45. package/src/theme-proposals.js +143 -55
  46. package/src/theme-resolve.js +14 -1
  47. package/src/theme-validation.js +70 -38
  48. package/src/token-reach.js +20 -0
  49. package/src/typed-page-reference.js +25 -3
  50. package/src/typed-pages.js +73 -14
  51. package/src/verbs/authors.js +198 -33
  52. package/src/verbs/changelog.js +23 -2
  53. package/src/verbs/delivery-check.js +43 -9
  54. package/src/verbs/index.js +4 -2
  55. package/src/verbs/media-images.js +4 -4
  56. package/src/verbs/pages-push.js +138 -67
  57. package/src/verbs/plan.js +28 -20
  58. package/src/verbs/pull.js +226 -26
  59. package/src/verbs/theme-push.js +59 -15
  60. package/src/verbs/theme-resolve.js +109 -11
  61. package/src/verbs/validate.js +97 -16
  62. package/src/workspace-check.js +4 -4
  63. package/src/workspace-context-usage.js +180 -0
  64. package/src/workspace.js +48 -1
  65. package/test/fixtures/default-site-theme.json +1 -1
@@ -12,10 +12,11 @@ import {
12
12
  wcagRatio,
13
13
  } from "@taprootio/espalier/shared/theme";
14
14
 
15
- import { CHROME_NAVIGATION_UNAVAILABLE_MESSAGE } from "./chrome-input.js";
15
+ import { CHROME_NAVIGATION_UNAVAILABLE_MESSAGE, describeSkippedLinks } from "./chrome-input.js";
16
16
  import { CHROME_UNAVAILABLE_MESSAGE, decodeChromePair, floorTo } from "./chrome-output.js";
17
17
  import { SiteAuthoringError } from "./errors.js";
18
18
  import { loadEspalierShared } from "./espalier-shared.js";
19
+ import { notCountedLine, statusPaintLines, TEXT_USED_IN, withTextUsedIn } from "./status-warning-paints.js";
19
20
  import { pinnedTheme } from "./theme-proposals.js";
20
21
  import { validateAndEncodeThemePair } from "./theme-validation.js";
21
22
  import { formatTokenPaints, getTokenDerivation } from "./token-reach.js";
@@ -465,8 +466,20 @@ export function formatThemeResolve(result) {
465
466
  ]));
466
467
  }
467
468
  }
469
+ if (result.statusWarningPaints !== undefined || result.statusWarningPaintsOmitted !== undefined) {
470
+ lines.push("", "Status color warnings");
471
+ const records = withTextUsedIn(result.statusWarningPaints, result[TEXT_USED_IN]);
472
+ for (const warning of new Set((records ?? []).map((record) => record.warning))) {
473
+ lines.push(` ${warning}`, ...statusPaintLines(records, warning).map((line) => ` ${line}`));
474
+ }
475
+ if (result.statusWarningPaintsOmitted !== undefined) {
476
+ lines.push(` ${result.statusWarningPaintsOmitted} more status warning(s) have no paint information; run with --json for the count.`);
477
+ }
478
+ }
479
+ if (result.contextUsageSkipped !== undefined) lines.push("", ...notCountedLine(result.contextUsageSkipped));
468
480
  if (result.chromeUnavailable) lines.push("", CHROME_UNAVAILABLE_MESSAGE);
469
481
  if (result.chromeNavigationUnavailable) lines.push("", CHROME_NAVIGATION_UNAVAILABLE_MESSAGE);
482
+ if (result.skippedNavigationLinks !== undefined) lines.push("", describeSkippedLinks(result.skippedNavigationLinks));
470
483
  const { belowAa, pairs } = result.contrast;
471
484
  const measured = result.chromeUnavailable ? " measured" : "";
472
485
  const codes = [...new Set(result.flags.items.map((flag) => flag.code))];
@@ -534,7 +534,8 @@ export function abbreviateThemeContext(context, maximumLength, position) {
534
534
  }
535
535
 
536
536
  function componentPropertyReflowWarnings(lightTheme, darkTheme) {
537
- const properties = getSettableComponentProperties().filter(({ syntax }) => syntax !== "color");
537
+ // Espalier marks a property paintOnly when its value cannot move layout, so a scheme difference there is harmless.
538
+ const properties = getSettableComponentProperties().filter(({ syntax, paintOnly }) => syntax !== "color" && paintOnly !== true);
538
539
  const contexts = sharedDeclaredThemeContextNames(lightTheme, darkTheme);
539
540
  const prefix = "theme.component_property_scheme_differs: ";
540
541
  const warnings = [];
@@ -547,7 +548,7 @@ function componentPropertyReflowWarnings(lightTheme, darkTheme) {
547
548
  if (lightComparable === darkComparable) continue;
548
549
  const lightValue = displayComponentProperty(light, lightComparable, property.unit);
549
550
  const darkValue = displayComponentProperty(dark, darkComparable, property.unit);
550
- const details = ` ${property.name} is ${lightValue} in light and ${darkValue} in dark.`;
551
+ const details = ` ${property.name} can move layout and is ${lightValue} in light and ${darkValue} in dark.`;
551
552
  const nameBudget = Math.min(LIMITS.diagnosticScalars, MAXIMUM_THEME_WARNING_SCALARS)
552
553
  - prefix.length - "contexts.".length - details.length;
553
554
  const surface = context === null ? "root" : `contexts.${abbreviateThemeContext(context, nameBudget, position)}`;
@@ -575,7 +576,9 @@ function boundedThemeWarnings(allWarnings) {
575
576
 
576
577
  export function validateAndEncodeThemePair(lightTheme, darkTheme) {
577
578
  const { light, dark, warnings, inert } = checkThemePair(lightTheme, darkTheme);
578
- return { light, dark, ...boundedThemeWarnings([...warnings, ...inert]) };
579
+ const all = [...warnings, ...inert];
580
+ // The complete list, for callers that must select before the publication cap.
581
+ return Object.defineProperty({ light, dark, ...boundedThemeWarnings(all) }, "completeWarnings", { value: all });
579
582
  }
580
583
 
581
584
  /**
@@ -611,6 +614,61 @@ export function withChromeWarnings(themes, chromeWarnings) {
611
614
  return Object.defineProperty({ ...themes, ...bounded }, "warningGroups", { value: themes.warningGroups });
612
615
  }
613
616
 
617
+ const THEME_REFUSED = "theme.validation_failed";
618
+
619
+ function ordinaryRefusalField(message) {
620
+ return /^\s*(?:light|dark):\s*Every entry in ([A-Za-z0-9_.-]+)/u.exec(message)?.[1]
621
+ ?? /^\s*(?:light|dark):\s*([A-Za-z0-9_.-]+)/u.exec(message)?.[1]
622
+ ?? (/^\s*contexts\b/u.test(message) ? "contexts" : undefined);
623
+ }
624
+
625
+ function componentRefusal(finding, espalierMessage) {
626
+ const { scheme, context, property, code } = finding;
627
+ const field = [`${scheme}Theme`];
628
+ if (context !== null) field.push("contexts", context);
629
+ field.push("componentProperties");
630
+ if (property !== null) field.push(property);
631
+ // Espalier suggests the nearest settable name even for unrelated inputs.
632
+ const unknownProperty = code === "unknown" && property !== null;
633
+ const nearest = unknownProperty
634
+ ? closeFieldMatch(property.slice("--esp-".length), getSettableComponentProperties().map(({ name }) =>
635
+ name.slice("--esp-".length)))
636
+ : undefined;
637
+ const fullName = nearest === undefined ? undefined : "--esp-" + nearest;
638
+ const message = unknownProperty
639
+ ? `Unknown component property '${property}'.${unknownFieldHint(fullName)}`
640
+ : `Espalier rejected the theme: ${espalierMessage}`;
641
+ return { field: field.join("."), message, alternatives: fullName === undefined ? undefined : [fullName] };
642
+ }
643
+
644
+ /**
645
+ * One refusal naming every problem, ordinary errors first. The top-level field and message are the first
646
+ * problem's; the rest ride in `error.problems` (TR01419).
647
+ */
648
+ function refuseTheme(errors, findings) {
649
+ const ordinaryCount = Math.max(0, errors.length - findings.length);
650
+ const problems = [
651
+ ...errors.slice(0, ordinaryCount).map((message) => ({
652
+ code: THEME_REFUSED,
653
+ field: ordinaryRefusalField(message),
654
+ message: `Espalier rejected the theme: ${message}`,
655
+ })),
656
+ ...findings.map((finding, index) => ({
657
+ code: THEME_REFUSED,
658
+ ...componentRefusal(finding, errors[ordinaryCount + index] ?? "The theme pair is invalid."),
659
+ })),
660
+ ];
661
+ if (problems.length === 0) {
662
+ problems.push({ code: THEME_REFUSED, message: "Espalier rejected the theme: The theme pair is invalid." });
663
+ }
664
+ const [first] = problems;
665
+ const error = new SiteAuthoringError(THEME_REFUSED, first.message, {
666
+ field: first.field,
667
+ alternatives: first.alternatives,
668
+ });
669
+ throw error.withProblems(problems);
670
+ }
671
+
614
672
  function checkThemePair(lightTheme, darkTheme) {
615
673
  requireCompleteTheme(lightTheme, "light");
616
674
  requireCompleteTheme(darkTheme, "dark");
@@ -631,44 +689,18 @@ function checkThemePair(lightTheme, darkTheme) {
631
689
  }
632
690
 
633
691
  const result = validateThemePair(light, dark);
634
- // Espalier appends one error per component finding after its ordinary errors.
635
- const findings = result.valid ? [] : validateComponentProperties(light, dark);
636
- const componentFinding = findings.length === result.errors.length ? findings[0] : undefined;
637
- const first = result.errors[0] ?? "The theme pair is invalid.";
638
- if (!result.valid && componentFinding === undefined) {
639
- const field = /^\s*(?:light|dark):\s*Every entry in ([A-Za-z0-9_.-]+)/u.exec(first)?.[1]
640
- ?? /^\s*(?:light|dark):\s*([A-Za-z0-9_.-]+)/u.exec(first)?.[1]
641
- ?? (/^\s*contexts\b/u.test(first) ? "contexts" : undefined);
642
- throw new SiteAuthoringError(
643
- "theme.validation_failed",
644
- `Espalier rejected the theme: ${first}`,
645
- { field },
646
- );
692
+ if (!result.valid) {
693
+ // Espalier appends one error per component finding after its ordinary errors (TR01419).
694
+ const findings = validateComponentProperties(light, dark);
695
+ // An external stylesheet is refused before a theme whose only errors are component findings.
696
+ if (findings.length >= result.errors.length) {
697
+ refuseAgentStylesheets(lightTheme, "light");
698
+ refuseAgentStylesheets(darkTheme, "dark");
699
+ }
700
+ refuseTheme(result.errors, findings);
647
701
  }
648
702
  refuseAgentStylesheets(lightTheme, "light");
649
703
  refuseAgentStylesheets(darkTheme, "dark");
650
- if (componentFinding !== undefined) {
651
- const { scheme, context, property, code } = componentFinding;
652
- const field = [`${scheme}Theme`];
653
- if (context !== null) field.push("contexts", context);
654
- field.push("componentProperties");
655
- if (property !== null) field.push(property);
656
- // Espalier suggests the nearest settable name even for unrelated inputs.
657
- const unknownProperty = code === "unknown" && property !== null;
658
- const nearest = unknownProperty
659
- ? closeFieldMatch(property.slice("--esp-".length), getSettableComponentProperties().map(({ name }) =>
660
- name.slice("--esp-".length)))
661
- : undefined;
662
- const fullName = nearest === undefined ? undefined : "--esp-" + nearest;
663
- const message = unknownProperty
664
- ? `Unknown component property '${property}'.${unknownFieldHint(fullName)}`
665
- : `Espalier rejected the theme: ${first}`;
666
- throw new SiteAuthoringError(
667
- "theme.validation_failed",
668
- message,
669
- { field: field.join("."), alternatives: fullName === undefined ? undefined : [fullName] },
670
- );
671
- }
672
704
  return {
673
705
  light,
674
706
  dark,
@@ -59,7 +59,22 @@ const BORDER_PAINT_NOTES = [
59
59
  text: "--esp-blockquote-glyph-color overrides the quote glyph. When unset, the glyph follows the bar.",
60
60
  },
61
61
  ];
62
+ // A form field's row repeats on layer2 to layer4: the layer is chosen by the surface the field sits on.
63
+ const FORM_FIELD_LAYER_NOTE = {
64
+ token: "--esp-color-layer-N",
65
+ component: "esp-input",
66
+ part: "dynamic",
67
+ state: "ordinary",
68
+ label: "field surface layer fill",
69
+ folder: "input",
70
+ text: "A form field paints one layer above the surface it sits on: a field on a layer1 surface paints layer2, "
71
+ + "on layer2 paints layer3, and on layer3 paints layer4.",
72
+ };
73
+ const formFieldLayerNote = (level) => ({ ...FORM_FIELD_LAYER_NOTE, token: `--esp-color-layer-${level}` });
62
74
  const COMPONENT_PAINT_NOTES = {
75
+ layer2: [formFieldLayerNote(2)],
76
+ layer3: [formFieldLayerNote(3)],
77
+ layer4: [formFieldLayerNote(4)],
63
78
  border: BORDER_PAINT_NOTES,
64
79
  headings: [1, 2, 3, 4].map((level) => ({
65
80
  token: "--esp-color-headings",
@@ -88,6 +103,11 @@ function getComponentPaints(name) {
88
103
  return manifestPaintsByCssName.get(semanticToCSS(name));
89
104
  }
90
105
 
106
+ /** The components whose paint rows name this semantic token, in manifest order. */
107
+ export function getPaintingComponents(name) {
108
+ return [...new Set((getComponentPaints(name) ?? []).map(({ component }) => component).filter(Boolean))];
109
+ }
110
+
91
111
  export function getTokenDerivation(name) {
92
112
  return DERIVATIONS.get(name) ?? null;
93
113
  }
@@ -61,6 +61,27 @@ const FIELD_HELP = Object.freeze({
61
61
  "The date the page is about or was originally published. Set it to preserve an imported date; omit it to use the "
62
62
  + "first publication date. An empty value clears it.",
63
63
  },
64
+ displayAuthor: {
65
+ type: "site author handle",
66
+ required: false,
67
+ description:
68
+ "The site author the byline shows instead of the member who wrote the page, such as jane-doe. Every handle "
69
+ + "names an author, including none; a member's email address is refused. A page with a display author carries no "
70
+ + "trace of the member and stays off their Taproot profile. Omit it to leave the site's value alone; a quoted "
71
+ + "empty value (\"\") clears it and a bare key is refused. It can be changed at any time, but a page that must be kept apart from the member needs it "
72
+ + "before the page is first published: a page already published under the member's name was public with it. "
73
+ + "An unknown handle is refused (pages.display_author_unknown); offline validate only warns "
74
+ + "(pages.display_author_unverified) about one authors.json lacks.",
75
+ },
76
+ showOnProfile: {
77
+ type: "true or false",
78
+ required: false,
79
+ description:
80
+ "false keeps a member's page (one with no display author) off that member's Taproot profile; it keeps its byline "
81
+ + "and profile link. Omit it to leave "
82
+ + "the site's setting alone. Only true and false are accepted (pages.show_on_profile_invalid). The profile "
83
+ + "changes after the page is published and its release goes live. A displayAuthor keeps a page apart entirely.",
84
+ },
64
85
  coverImage: {
65
86
  type: "media reference",
66
87
  required: false,
@@ -88,7 +109,8 @@ const FIELD_HELP = Object.freeze({
88
109
  "The Taproot place being reviewed. The site fills in its name, address and coordinates from this record. Find "
89
110
  + "it with 'places search <name and city>' and 'places select <googlePlaceId> <sessionToken>'. The site publishes the "
90
111
  + "place's category in the byline; change it for this site with "
91
- + "'places category set <placeId> <category>'.",
112
+ + "'places category set <placeId> <category>'. A category override affects the release alone, never the "
113
+ + "page's stored revision.",
92
114
  },
93
115
  place: {
94
116
  type: "UUID",
@@ -397,7 +419,7 @@ function legalReference() {
397
419
  templateType: "TEMPLATE_TYPE_LEGAL",
398
420
  sourceRule:
399
421
  "Pull writes a .pm.json source containing template legal and data with documentKey, documentRole, summaryOfChanges, material and body. "
400
- + "Edit that source to change the draft; Markdown is not supported. To create one, add a .pm.json source and a manifest pages entry with file, title and path, without a pageId. Version, effectiveDate and supersedesVersion are assigned by Taproot and must not be authored.",
422
+ + "Edit that source to change the draft; Markdown is not supported. To create one, add a .pm.json source and a manifest pages entry with file, title and path, without a pageId. A pull keeps that never-saved entry and its file (keptPendingPages in the result) unless a page on the site already holds its path, then it refuses; save it with 'login --legal-drafts' and '--legal-drafts pages push'. Version, effectiveDate and supersedesVersion are assigned by Taproot and must not be authored.",
401
423
  }),
402
424
  fields: Object.freeze([
403
425
  Object.freeze({ name: "title", description: "The page title. It prints as the page's h1, so the body should not open with its own title." }),
@@ -507,7 +529,7 @@ function typedReference(type) {
507
529
  purpose: generated
508
530
  ? "The pulled form, and the only one: { template, data }. Path comes from the manifest; title and description "
509
531
  + "are the custom ones in data."
510
- : "The pulled form: { template, displayDate?, coverImageId?, data }. Title, path and description come from the manifest.",
532
+ : "The pulled form: { template, displayDate?, displayAuthor?, showOnProfile?, coverImageId?, data }. Title, path and description come from the manifest.",
511
533
  dataFields: Object.freeze(details.dataFields),
512
534
  }),
513
535
  ]),
@@ -1,4 +1,5 @@
1
1
  import { FREE_FORM_TEMPLATE_VERSION, TEMPLATE_TYPE_FREE_FORM } from "./api.js";
2
+ import { normalizeAuthorHandle } from "./authors-contract.js";
2
3
  import { authoredTagSlug, validateAuthoredTagNames } from "./authored-tag-names.js";
3
4
  import { isVideoEmbedId } from "./content/video-embed-url.js";
4
5
  import { hasControlCharacter, SiteAuthoringError } from "./errors.js";
@@ -15,7 +16,7 @@ import { recipeStepProblems } from "./recipe-step-contract.js";
15
16
  * Free-form keeps its historical shape (the ProseMirror document itself). The
16
17
  * other templates use a small wrapper:
17
18
  *
18
- * { "template": "recipe", "displayDate": "2024-05-01", "coverImageId": "…", "data": { … } }
19
+ * { "template": "recipe", "displayDate": "2024-05-01", "displayAuthor": "jane-doe", "showOnProfile": false, "coverImageId": "…", "data": { … } }
19
20
  *
20
21
  * `pull` writes that wrapper, a Markdown source is converted into it, and
21
22
  * `pages push` turns it into the API's `PageTemplate`. Because all three meet
@@ -63,7 +64,7 @@ export const SHARED_FRONT_MATTER_KEYS = Object.freeze(["title", "path", "descrip
63
64
  * its bare document, which has nowhere to carry them, so it does not accept
64
65
  * them.
65
66
  */
66
- const TYPED_PAGE_FRONT_MATTER_KEYS = Object.freeze(["displayDate", "coverImage", "tags"]);
67
+ const TYPED_PAGE_FRONT_MATTER_KEYS = Object.freeze(["displayDate", "displayAuthor", "showOnProfile", "coverImage", "tags"]);
67
68
 
68
69
  /** Front-matter fields only one template accepts. Others are refused for it. */
69
70
  const TEMPLATE_FRONT_MATTER_KEYS = Object.freeze({
@@ -379,6 +380,43 @@ export function requireDisplayDate(value, file) {
379
380
  return value;
380
381
  }
381
382
 
383
+ /**
384
+ * A page's display author (TR01402): a site author's handle, folded, or ""
385
+ * to clear it. Every handle names an author, including `none`; a member's
386
+ * email address is not one, because only a site author can be a byline.
387
+ */
388
+ export function requireDisplayAuthor(value, file) {
389
+ if (value === "") return value;
390
+ const handle = normalizeAuthorHandle(value);
391
+ if (handle === undefined) {
392
+ throw fail(
393
+ "pages.display_author_invalid",
394
+ `'${file}' declares displayAuthor '${typeof value === "string" ? value.slice(0, 80) : ""}', which is not a `
395
+ + "site author's handle (lowercase letters, digits and single hyphens, such as jane-doe). Use '' to clear it.",
396
+ file,
397
+ );
398
+ }
399
+ return handle;
400
+ }
401
+
402
+ /**
403
+ * Whether the page may appear on its author's Taproot profile (TR01403): the
404
+ * literal `true` or `false`. A `.pm.json` document holds a JSON boolean; a
405
+ * Markdown front-matter line holds the text (`fromText`), which an unquoted or
406
+ * quoted literal both give. Anything else, a JSON string included, is refused
407
+ * so a typo never leaves a page on a profile its author meant to keep it off.
408
+ */
409
+ export function requireShowOnProfile(value, file, { fromText = false } = {}) {
410
+ if (typeof value === "boolean") return value;
411
+ if (fromText && (value === "true" || value === "false")) return value === "true";
412
+ throw fail(
413
+ "pages.show_on_profile_invalid",
414
+ `'${file}' declares showOnProfile ${typeof value === "string" ? `'${value.slice(0, 80)}'` : "with a value"}, which is `
415
+ + `not ${fromText ? "true or false" : "a JSON boolean (true or false)"}.`,
416
+ file,
417
+ );
418
+ }
419
+
382
420
  // ── Canonical data per template ──────────────────────────────────────────────
383
421
 
384
422
  const INGREDIENT_KEYS = ["rawText", "quantity", "unit", "name", "parsed"];
@@ -635,10 +673,12 @@ function canonicalSourceData(template, data, file) {
635
673
  * The canonical workspace document for a typed page, with keys in one fixed
636
674
  * order. The order is part of the byte-stability contract.
637
675
  */
638
- function typedDocument(template, { displayDate, coverImageId, tags, data }) {
676
+ function typedDocument(template, { displayDate, displayAuthor, showOnProfile, coverImageId, tags, data }) {
639
677
  return {
640
678
  template,
641
679
  ...(displayDate === undefined ? {} : { displayDate }),
680
+ ...(displayAuthor === undefined ? {} : { displayAuthor }),
681
+ ...(showOnProfile === undefined ? {} : { showOnProfile }),
642
682
  ...(coverImageId === undefined ? {} : { coverImageId }),
643
683
  ...(tags === undefined ? {} : { tags }),
644
684
  data,
@@ -647,7 +687,7 @@ function typedDocument(template, { displayDate, coverImageId, tags, data }) {
647
687
 
648
688
  /** Validates a parsed `.pm.json` that declares a template, and returns its canonical form. */
649
689
  export function typedDocumentFromJson(parsed, file) {
650
- requireKeys(parsed, ["template", "displayDate", "coverImageId", "tags", "data"], file, "document");
690
+ requireKeys(parsed, ["template", "displayDate", "displayAuthor", "showOnProfile", "coverImageId", "tags", "data"], file, "document");
651
691
  const template = requireTemplateName(parsed.template, file);
652
692
  const tags = Object.hasOwn(parsed, "tags") ? requireSourceTags(template, parsed.tags, file).names : undefined;
653
693
  if (template === TEMPLATE_FREE_FORM) {
@@ -658,21 +698,25 @@ export function typedDocumentFromJson(parsed, file) {
658
698
  file,
659
699
  );
660
700
  }
661
- if ((template === TEMPLATE_GENERATED || template === TEMPLATE_LEGAL) && (parsed.displayDate !== undefined || parsed.coverImageId !== undefined)) {
701
+ if ((template === TEMPLATE_GENERATED || template === TEMPLATE_LEGAL) && (parsed.displayDate !== undefined || parsed.displayAuthor !== undefined || parsed.showOnProfile !== undefined || parsed.coverImageId !== undefined)) {
662
702
  throw fail(
663
703
  "pages.document_shape",
664
- `'${file}' is a ${template} page, which has no displayDate or coverImageId of its own: its document is `
704
+ `'${file}' is a ${template} page, which has no displayDate, displayAuthor, showOnProfile or coverImageId of its own: its document is `
665
705
  + "{ template, data }.",
666
706
  file,
667
707
  );
668
708
  }
669
709
  const displayDate = parsed.displayDate === undefined ? undefined : requireDisplayDate(parsed.displayDate, file);
710
+ const displayAuthor = parsed.displayAuthor === undefined ? undefined : requireDisplayAuthor(parsed.displayAuthor, file);
711
+ const showOnProfile = parsed.showOnProfile === undefined ? undefined : requireShowOnProfile(parsed.showOnProfile, file);
670
712
  let coverImageId;
671
713
  if (parsed.coverImageId !== undefined) {
672
714
  coverImageId = parsed.coverImageId === "" ? "" : requireIdentifier(parsed.coverImageId, file, "coverImageId");
673
715
  }
674
716
  return typedDocument(template, {
675
717
  displayDate,
718
+ displayAuthor,
719
+ showOnProfile,
676
720
  coverImageId,
677
721
  tags,
678
722
  data: canonicalSourceData(template, parsed.data, file),
@@ -784,6 +828,11 @@ export function workspaceDocumentFromPage(page, listedTemplateType) {
784
828
  displayDate: !generated && typeof page.displayDate === "string" && page.displayDate !== ""
785
829
  ? page.displayDate
786
830
  : undefined,
831
+ displayAuthor: !generated && typeof page.displayAuthor === "string" && page.displayAuthor !== ""
832
+ ? normalizeAuthorHandle(page.displayAuthor)
833
+ : undefined,
834
+ // Written only when the page is kept off its author's profile, as the date is written only when there is one.
835
+ showOnProfile: !generated && page.showOnProfile === false ? false : undefined,
787
836
  coverImageId: !generated && typeof page.coverImageId === "string" && page.coverImageId !== ""
788
837
  ? page.coverImageId
789
838
  : undefined,
@@ -821,6 +870,10 @@ export function sentDisplayDate(wireType) {
821
870
  return name !== undefined && name !== TEMPLATE_FREE_FORM && name !== TEMPLATE_GENERATED && name !== TEMPLATE_LEGAL;
822
871
  }
823
872
 
873
+ /** `displayAuthor` and `showOnProfile` travel with the same four byline templates as `displayDate` (TR01402, TR01403). */
874
+ export const sentDisplayAuthor = sentDisplayDate;
875
+ export const sentShowOnProfile = sentDisplayDate;
876
+
824
877
  // The nodes the API accepts in an album or recipe introduction
825
878
  // (`MembershipTermsDocumentRules.AllowedNodeTypes`). A page body accepts
826
879
  // more, such as `section` and `inlineFacts`, so a document valid as a body can
@@ -1019,6 +1072,8 @@ export function wirePageFields(document_) {
1019
1072
  if ([TEMPLATE_FREE_FORM, TEMPLATE_LEGAL].includes(documentTemplate(document_))) return {};
1020
1073
  return definedEntries([
1021
1074
  ["displayDate", document_.displayDate],
1075
+ ["displayAuthor", document_.displayAuthor],
1076
+ ["showOnProfile", document_.showOnProfile],
1022
1077
  ["coverImageId", document_.coverImageId],
1023
1078
  ]);
1024
1079
  }
@@ -1175,14 +1230,14 @@ async function parseRecipeBody(markdown, { file, convert, convertStep, firstLine
1175
1230
  }
1176
1231
  refuseRecipeStepProblems(problems);
1177
1232
  return {
1178
- introductionBody: lead.trim() === "" ? undefined : await convert(lead),
1233
+ introductionBody: lead.trim() === "" ? undefined : await convert(lead, firstLine),
1179
1234
  ingredientGroups,
1180
1235
  instructionSections,
1181
1236
  };
1182
1237
  }
1183
1238
 
1184
- async function parseAlbumBody(markdown, { file, convert, resolveImage }) {
1185
- const { lead, sections } = splitSections(markdown);
1239
+ async function parseAlbumBody(markdown, { file, convert, resolveImage, firstLine }) {
1240
+ const { lead, sections } = splitSections(markdown, firstLine);
1186
1241
  requireSectionTitles(sections, [ALBUM_IMAGES_HEADING], file, TEMPLATE_ALBUM);
1187
1242
  const images = [];
1188
1243
  for (const line of sections[0].lines) {
@@ -1202,7 +1257,7 @@ async function parseAlbumBody(markdown, { file, convert, resolveImage }) {
1202
1257
  if (images.length === 0) {
1203
1258
  throw fail("pages.album_images_missing", `'${file}' is an album whose Images section lists no images.`, file);
1204
1259
  }
1205
- return { introductionBody: lead.trim() === "" ? undefined : await convert(lead), images };
1260
+ return { introductionBody: lead.trim() === "" ? undefined : await convert(lead, firstLine), images };
1206
1261
  }
1207
1262
 
1208
1263
  function parseCount(fields, key, file, maximum) {
@@ -1281,6 +1336,10 @@ export async function typedDocumentFromMarkdown({
1281
1336
  if (template === TEMPLATE_LEGAL) throw legalMarkdownFault(file);
1282
1337
  const tags = fields.has("tags") ? parseMarkdownTags(fields.get("tags"), file) : undefined;
1283
1338
  const displayDate = fields.has("displayDate") ? requireDisplayDate(fields.get("displayDate"), file) : undefined;
1339
+ const displayAuthor = fields.has("displayAuthor") ? requireDisplayAuthor(fields.get("displayAuthor"), file) : undefined;
1340
+ const showOnProfile = fields.has("showOnProfile")
1341
+ ? requireShowOnProfile(fields.get("showOnProfile"), file, { fromText: true })
1342
+ : undefined;
1284
1343
  let coverImageId;
1285
1344
  if (fields.has("coverImage")) {
1286
1345
  const reference = fields.get("coverImage");
@@ -1288,7 +1347,7 @@ export async function typedDocumentFromMarkdown({
1288
1347
  }
1289
1348
  let data;
1290
1349
  if (template === TEMPLATE_ARTICLE) {
1291
- data = { body: await convert(markdown), place: fields.get("place") };
1350
+ data = { body: await convert(markdown, firstLine), place: fields.get("place") };
1292
1351
  } else if (template === TEMPLATE_PLACE_REVIEW) {
1293
1352
  const placeId = fields.get("placeId");
1294
1353
  const rating = fields.get("rating");
@@ -1300,10 +1359,10 @@ export async function typedDocumentFromMarkdown({
1300
1359
  file,
1301
1360
  );
1302
1361
  }
1303
- data = { placeId, rating, body: await convert(markdown) };
1362
+ data = { placeId, rating, body: await convert(markdown, firstLine) };
1304
1363
  } else if (template === TEMPLATE_ALBUM) {
1305
1364
  data = {
1306
- ...(await parseAlbumBody(markdown, { file, convert, resolveImage })),
1365
+ ...(await parseAlbumBody(markdown, { file, convert, resolveImage, firstLine })),
1307
1366
  seamless: parseFlag(fields, "seamless", file),
1308
1367
  borderWidth: parseCount(fields, "borderWidth", file, ALBUM_MAXIMUM_BORDER_WIDTH),
1309
1368
  place: fields.get("place"),
@@ -1324,7 +1383,7 @@ export async function typedDocumentFromMarkdown({
1324
1383
  return typedDocumentFromJson(
1325
1384
  {
1326
1385
  template,
1327
- ...definedEntries([["displayDate", displayDate], ["coverImageId", coverImageId], ["tags", tags]]),
1386
+ ...definedEntries([["displayDate", displayDate], ["displayAuthor", displayAuthor], ["showOnProfile", showOnProfile], ["coverImageId", coverImageId], ["tags", tags]]),
1328
1387
  data: withoutUndefined(data),
1329
1388
  },
1330
1389
  file,