create-ailk 0.20.0 → 0.21.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 (83) hide show
  1. package/README.md +21 -1
  2. package/component-catalog.json +184 -6
  3. package/component-catalog.md +20 -9
  4. package/dist/apply-design.d.ts +9 -0
  5. package/dist/apply-design.js +78 -31
  6. package/dist/design-home.d.ts +54 -11
  7. package/dist/design-home.js +160 -22
  8. package/dist/lib/design-checks.d.ts +6 -1
  9. package/dist/lib/design-checks.js +23 -2
  10. package/dist/programmatic.js +44 -20
  11. package/dist/site-roster.d.ts +4 -2
  12. package/dist/site-roster.js +7 -5
  13. package/dist/starter-grid.js +16 -0
  14. package/dist/surfaces.js +11 -0
  15. package/dist/sync-routes.d.ts +28 -0
  16. package/dist/sync-routes.js +123 -1
  17. package/dist/update.d.ts +6 -1
  18. package/dist/update.js +120 -18
  19. package/package.json +3 -3
  20. package/site-templates/_base/ailk-template.json +2 -2
  21. package/site-templates/_base/content/en/WorkingAgreementPage/working-agreement.mdx +78 -0
  22. package/site-templates/designs/minimalism/DESIGN.md +1 -1
  23. package/site-templates/designs/minimalism/contact/local-business-service.mdx +23 -0
  24. package/site-templates/designs/minimalism/contact/organization-product.mdx +23 -0
  25. package/site-templates/designs/minimalism/contact/organization-service.mdx +23 -0
  26. package/site-templates/designs/minimalism/contact/person-service.mdx +23 -0
  27. package/site-templates/marketing-site/TEMPLATE-MANIFEST.json +18 -1
  28. package/site-templates/marketing-site/TEMPLATE-MANIFEST.md +11 -0
  29. package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.json +18 -1
  30. package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.md +34 -23
  31. package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.json +18 -1
  32. package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.md +33 -23
  33. package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.json +18 -1
  34. package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.md +33 -23
  35. package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.json +18 -1
  36. package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.md +31 -21
  37. package/templates/README.md +26 -25
  38. package/templates/apps/api/CLAUDE.md +7 -3
  39. package/templates/apps/api/jest.config.cjs +1 -0
  40. package/templates/apps/api/src/routes/project-listings/__tests__/drafts.test.ts +26 -0
  41. package/templates/apps/api/src/services/project-listings.ts +6 -1
  42. package/templates/apps/mcp/__tests__/catalog-drift.test.ts +69 -61
  43. package/templates/apps/mcp/jest.config.cjs +1 -0
  44. package/templates/apps/web/CLAUDE.md +26 -1
  45. package/templates/apps/web/app/[locale]/about/[slug]/page.tsx +46 -0
  46. package/templates/apps/web/app/[locale]/about/__tests__/about-routes.test.tsx +350 -0
  47. package/templates/apps/web/app/[locale]/about/page.tsx +83 -1
  48. package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +2 -2
  49. package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +2 -2
  50. package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +7 -0
  51. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-magnet.test.ts +138 -0
  52. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-text.test.ts +17 -0
  53. package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +347 -0
  54. package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +73 -0
  55. package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +5 -3
  56. package/templates/apps/web/app/[locale]/contact/contact-form-magnet.ts +77 -0
  57. package/templates/apps/web/app/[locale]/contact/contact-form-text.ts +2 -0
  58. package/templates/apps/web/app/[locale]/contact/contact.actions.ts +35 -3
  59. package/templates/apps/web/app/[locale]/contact/page.tsx +81 -9
  60. package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +2 -2
  61. package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +1 -1
  62. package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +2 -2
  63. package/templates/apps/web/app/[locale]/layout.tsx +23 -2
  64. package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +2 -2
  65. package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +2 -2
  66. package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +2 -2
  67. package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +1 -1
  68. package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +1 -1
  69. package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +1 -1
  70. package/templates/apps/web/app/[locale]/working-agreement/__tests__/page.test.tsx +63 -0
  71. package/templates/apps/web/app/[locale]/working-agreement/page.tsx +41 -0
  72. package/templates/apps/web/jest.config.cjs +1 -0
  73. package/templates/apps/web/lib/__tests__/deck-page.test.ts +244 -0
  74. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +4 -2
  75. package/templates/apps/web/lib/deck-page.ts +186 -0
  76. package/templates/apps/web/messages/en.json +16 -5
  77. package/templates/database/CHANGELOG.md +9 -0
  78. package/templates/database/__tests__/seed.test.ts +39 -2
  79. package/templates/database/jest.config.cjs +1 -0
  80. package/templates/database/package.json +1 -1
  81. package/templates/database/seed.ts +29 -0
  82. package/templates/tools/jest/pin-timezone.cjs +34 -0
  83. package/versions.json +34 -34
@@ -19,7 +19,7 @@ import { dirname, join, relative, resolve, sep } from "node:path";
19
19
  import { parseArgs } from "node:util";
20
20
  import { planDesignMd } from "./apply-design-md.js";
21
21
  import { compileDesignFonts, compileDesignTheme } from "./design-compile.js";
22
- import { HOME_PAGE_PATH, designHomeSeeds, planDesignHome, shapeHomePath, shippedHomeSeeds, } from "./design-home.js";
22
+ import { CONTACT_PAGE_PATH, DESIGN_SEED_PAGES, HOME_PAGE_PATH, designHomeSeeds, planDesignHome, shapeHomePath, shippedHomeSeeds, siteIdentityName, } from "./design-home.js";
23
23
  import { applyDesignPresets, readSectionLookCatalog, shippedPageTypes, validateDesignPresets, } from "./design-presets.js";
24
24
  import { resolveDesign, spliceThemeBlock } from "./design-scaffold.js";
25
25
  import { chromeKnobReaders, unreadChromeKnobs } from "./lib/chrome-readers.js";
@@ -194,6 +194,9 @@ export async function applyDesign(opts) {
194
194
  // #7743 D7 — the home seeds (the design's and every shipped design's), validated beside the presets.
195
195
  const designSeeds = designHomeSeeds(resolved, { designsDir: opts.designsDir, catalog });
196
196
  const shippedSeeds = shippedHomeSeeds({ designsDir: opts.designsDir, catalog });
197
+ // #8661 D11 — and the contact seeds, the same way.
198
+ const contactSeeds = designHomeSeeds(resolved, { designsDir: opts.designsDir, catalog, page: "contact" });
199
+ const shippedContactSeeds = shippedHomeSeeds({ designsDir: opts.designsDir, catalog, page: "contact" });
197
200
  // C5 — the design gate, fed the site's own key (D6). A Free design reads no key.
198
201
  if (!resolved.free) {
199
202
  const key = readSiteKey(targetAbs, env);
@@ -243,28 +246,44 @@ export async function applyDesign(opts) {
243
246
  const designMdNext = planDesignMd(resolved.dir, targetAbs);
244
247
  // #7743 D7 — the home is planned before the presets, so a seeded home is
245
248
  // written once, carrying both. The one `planDesignHome` call site here.
249
+ // #8661 D11 — the contact page is planned right after it, its heading named
250
+ // from the site's `siteIdentity.name`.
246
251
  const shape = roster?.template.shape;
247
- const target = designSeeds.find((seed) => seed.shape === shape);
248
- // The arc this site would take: the shape's seed, or (with no shape to pick one) any seed at all.
249
- const homeArc = target !== undefined || (shape === undefined && designSeeds.length > 0);
250
- const homePath = join(targetAbs, ...HOME_PAGE_PATH.split("/"));
251
- const current = existsSync(homePath) ? readFileSync(homePath, "utf8") : undefined;
252
- const homePlan = planDesignHome({
253
- current,
254
- shape,
255
- target,
256
- shapeHome: shape === undefined || current === undefined
257
- ? ""
258
- : readFileSync(shapeHomePath(shape, {
259
- siteTemplatesDir: opts.siteTemplatesDir,
260
- templatesDir,
261
- }), "utf8"),
262
- shippedSeeds,
263
- catalog: catalog(),
252
+ const siteName = siteIdentityName(siteMdxCurrent);
253
+ const plans = [
254
+ ["home", designSeeds, shippedSeeds],
255
+ ["contact", contactSeeds, shippedContactSeeds],
256
+ ].map(([page, pageSeeds, shippedPageSeeds]) => {
257
+ const target = pageSeeds.find((seed) => seed.shape === shape);
258
+ const path = join(targetAbs, ...DESIGN_SEED_PAGES[page].path.split("/"));
259
+ const current = existsSync(path) ? readFileSync(path, "utf8") : undefined;
260
+ const plan = planDesignHome({
261
+ page,
262
+ siteName,
263
+ current,
264
+ shape,
265
+ target,
266
+ shapeHome: shape === undefined || current === undefined
267
+ ? ""
268
+ : readFileSync(shapeHomePath(shape, { siteTemplatesDir: opts.siteTemplatesDir, templatesDir, page }), "utf8"),
269
+ shippedSeeds: shippedPageSeeds,
270
+ catalog: catalog(),
271
+ });
272
+ // The page this site would take: the shape's seed, or (with no shape to pick one) any seed at all.
273
+ const offered = target !== undefined || (shape === undefined && pageSeeds.length > 0);
274
+ const action = plan.outcome === "seeded" || plan.outcome === "restored" ? plan.outcome : undefined;
275
+ return { path, plan, offered, action };
264
276
  });
265
- const homeAction = homePlan.outcome === "seeded" || homePlan.outcome === "restored" ? homePlan.outcome : undefined;
277
+ const [homeSeeding, contactSeeding] = plans;
278
+ const homePlan = homeSeeding.plan;
279
+ const homeArc = homeSeeding.offered;
280
+ const homePath = homeSeeding.path;
281
+ const homeAction = homeSeeding.action;
282
+ const contactPlan = contactSeeding.plan;
283
+ const contactPath = contactSeeding.path;
284
+ const contactAction = contactSeeding.action;
266
285
  const pageWrites = [];
267
- if (roster !== undefined && (hasPresets || homeAction !== undefined)) {
286
+ if (roster !== undefined && (hasPresets || homeAction !== undefined || contactAction !== undefined)) {
268
287
  const pageTypes = new Set();
269
288
  for (const row of roster.rows) {
270
289
  const pageType = row.value["pageType"];
@@ -274,11 +293,17 @@ export async function applyDesign(opts) {
274
293
  const contentDir = join(targetAbs, "content");
275
294
  // An authored home kept from a design's arc is reported as kept, so no preset dresses it either (D3, F4).
276
295
  const homeKept = homePlan.outcome === "authored" && homeArc;
296
+ // #8661 D11 — likewise an authored contact page kept from the design's own.
297
+ const contactKept = contactPlan.outcome === "authored" && contactSeeding.offered;
277
298
  const pages = listMdxFiles(contentDir)
278
- .filter((path) => path !== siteMdxPath && !(homeKept && path === homePath))
299
+ .filter((path) => path !== siteMdxPath && !(homeKept && path === homePath) && !(contactKept && path === contactPath))
279
300
  .map((path) => ({
280
301
  path,
281
- text: path === homePath && homePlan.text !== undefined ? homePlan.text : readFileSync(path, "utf8"),
302
+ text: path === homePath && homePlan.text !== undefined
303
+ ? homePlan.text
304
+ : path === contactPath && contactPlan.text !== undefined
305
+ ? contactPlan.text
306
+ : readFileSync(path, "utf8"),
282
307
  }));
283
308
  const presetResult = hasPresets
284
309
  ? applyDesignPresets(pages, pkg.sections, { pageTypes })
@@ -286,14 +311,21 @@ export async function applyDesign(opts) {
286
311
  for (const page of pages) {
287
312
  const preset = presetResult.pages.find((p) => p.path === page.path);
288
313
  const home = page.path === homePath ? homeAction : undefined;
289
- if (preset === undefined && home === undefined)
314
+ const contact = page.path === contactPath ? contactAction : undefined;
315
+ if (preset === undefined && home === undefined && contact === undefined)
290
316
  continue;
291
317
  const fields = [
292
318
  ...new Set(presetResult.applied
293
319
  .filter((a) => a.path === page.path)
294
320
  .map((a) => `${a.sectionType}.${a.field}`)),
295
321
  ].sort();
296
- pageWrites.push({ path: page.path, text: preset?.text ?? page.text, fields, ...(home !== undefined ? { home } : {}) });
322
+ pageWrites.push({
323
+ path: page.path,
324
+ text: preset?.text ?? page.text,
325
+ fields,
326
+ ...(home !== undefined ? { home } : {}),
327
+ ...(contact !== undefined ? { contact } : {}),
328
+ });
297
329
  }
298
330
  }
299
331
  let manifest = "no-roster";
@@ -303,10 +335,14 @@ export async function applyDesign(opts) {
303
335
  if (roster.path === SITE_ROSTER_PATH) {
304
336
  manifestNext = planSiteManifestDesign(readFileSync(rosterAbs, "utf8"), { design: resolved.recorded, layout: chrome, theme }, rosterAbs);
305
337
  // #7743 D6 — the `/` row records the home as written, in the same single write.
306
- const home = pageWrites.find((page) => page.home !== undefined);
307
- if (home !== undefined) {
338
+ // #8661 — and the `/contact` row the contact page.
339
+ for (const page of ["home", "contact"]) {
340
+ const written = pageWrites.find((write) => write[page] !== undefined);
341
+ if (written === undefined)
342
+ continue;
308
343
  manifestNext =
309
- planHomeRecord(manifestNext ?? readFileSync(rosterAbs, "utf8"), home.text, catalog()) ?? manifestNext;
344
+ planHomeRecord(manifestNext ?? readFileSync(rosterAbs, "utf8"), written.text, catalog(), page) ??
345
+ manifestNext;
310
346
  }
311
347
  manifest = manifestNext === undefined ? "unchanged" : "recorded";
312
348
  }
@@ -321,7 +357,9 @@ export async function applyDesign(opts) {
321
357
  const path = siteRelative(targetAbs, page.path);
322
358
  changes.push(page.home !== undefined
323
359
  ? { path, kind: "home", action: page.home, fields: page.fields }
324
- : { path, kind: "preset", fields: page.fields });
360
+ : page.contact !== undefined
361
+ ? { path, kind: "contact", action: page.contact, fields: page.fields }
362
+ : { path, kind: "preset", fields: page.fields });
325
363
  }
326
364
  if (chromeNext !== chromeCurrent) {
327
365
  mkdirSync(dirname(chromePath), { recursive: true });
@@ -353,6 +391,8 @@ export async function applyDesign(opts) {
353
391
  manifest,
354
392
  home: homePlan.outcome,
355
393
  ...(homeArc ? { homeArc: true } : {}),
394
+ contact: contactPlan.outcome,
395
+ ...(contactSeeding.offered ? { contactSeed: true } : {}),
356
396
  ...(roster !== undefined ? { rosterPath: roster.path } : {}),
357
397
  ...(fontFamilies !== undefined ? { fonts: fontFamilies } : {}),
358
398
  ...(fontsUnwired ? { fontsUnwired: true } : {}),
@@ -370,16 +410,20 @@ export function formatApplyDesignReport(result) {
370
410
  for (const change of result.changes) {
371
411
  const suffix = change.kind === "preset"
372
412
  ? ` (${change.fields.join(", ")})`
373
- : change.kind === "home"
413
+ : change.kind === "home" || change.kind === "contact"
374
414
  ? ` (${[change.action, change.fields.join(", ")].filter((part) => part !== "").join("; ")})`
375
415
  : "";
376
416
  lines.push(` ${change.kind.padEnd(8)} ${change.path}${suffix}`);
377
417
  }
378
418
  const n = result.changes.length;
379
419
  const homeWritten = result.changes.some((change) => change.kind === "home");
420
+ const contactWritten = result.changes.some((change) => change.kind === "contact");
421
+ const contactNote = "the contact page's sections and title were replaced.";
380
422
  lines.push(`${n} file${n === 1 ? "" : "s"} changed. ${homeWritten
381
- ? "Routes are unchanged; the home page's sections were replaced."
382
- : "Routes and structured data are unchanged."}`);
423
+ ? `Routes are unchanged; the home page's sections were replaced.${contactWritten ? ` And ${contactNote}` : ""}`
424
+ : contactWritten
425
+ ? `Routes are unchanged; ${contactNote}`
426
+ : "Routes and structured data are unchanged."}`);
383
427
  }
384
428
  if (result.home === "authored" && result.homeArc === true) {
385
429
  lines.push(`home kept: ${HOME_PAGE_PATH} has authored sections — the ${result.design} home arc was not applied`);
@@ -387,6 +431,9 @@ export function formatApplyDesignReport(result) {
387
431
  else if (result.home === "no-shape" && result.homeArc === true) {
388
432
  lines.push("home not seeded: the site records no shape");
389
433
  }
434
+ if (result.contact === "authored" && result.contactSeed === true) {
435
+ lines.push(`contact kept: ${CONTACT_PAGE_PATH} has an authored title or sections — the ${result.design} contact page was not applied`);
436
+ }
390
437
  if (result.fonts !== undefined) {
391
438
  lines.push(`fonts: ${result.fonts.join(", ")} load at next build through next/font/google — a family that is not a variable Google font fails there`);
392
439
  }
@@ -2,7 +2,26 @@ import { type SectionLookCatalog } from "./design-presets.js";
2
2
  import type { ResolvedDesign } from "./design-scaffold.js";
3
3
  /** Where a site's home page lives, site-relative. */
4
4
  export declare const HOME_PAGE_PATH = "content/en/HomePage/home.mdx";
5
- /** One `home/<shape>.mdx` file of a design package (D1). */
5
+ /** Where a site's contact page lives, site-relative (#8661 D11). */
6
+ export declare const CONTACT_PAGE_PATH = "content/en/ContactPage/contact.mdx";
7
+ /**
8
+ * The pages a design may seed (#8661 D11), keyed by the design-package
9
+ * directory that holds their seeds (`home/<shape>.mdx`, `contact/<shape>.mdx`).
10
+ */
11
+ export declare const DESIGN_SEED_PAGES: {
12
+ readonly home: {
13
+ readonly pageType: "HomePage";
14
+ readonly path: "content/en/HomePage/home.mdx";
15
+ readonly route: "/";
16
+ };
17
+ readonly contact: {
18
+ readonly pageType: "ContactPage";
19
+ readonly path: "content/en/ContactPage/contact.mdx";
20
+ readonly route: "/contact";
21
+ };
22
+ };
23
+ export type DesignSeedPage = keyof typeof DESIGN_SEED_PAGES;
24
+ /** One `home/<shape>.mdx` (or `contact/<shape>.mdx`, #8661 D11) file of a design package (D1). */
6
25
  export interface HomeSeed {
7
26
  readonly shape: string;
8
27
  /** Absolute path, for refusals. */
@@ -11,34 +30,46 @@ export interface HomeSeed {
11
30
  }
12
31
  export type HomeSeedOutcome = "seeded" | "restored" | "unchanged" | "authored" | "no-shape" | "no-home";
13
32
  /**
14
- * Read and validate `<dir>/home/*` (D1). Refuses with a `DesignPackageError`
15
- * naming the file, before any write: a basename that is not a recognized
16
- * shape, a page whose `type` is not `HomePage`, `sections` that cannot be
17
- * located (or are not in the flow form a carry can splice), a section type
18
- * the catalog does not carry, or a `logoCloud` whose `logos` is not `[]`.
33
+ * Read and validate `<dir>/home/*` (D1), or `<dir>/contact/*` for
34
+ * `page: "contact"` (#8661 D11). Refuses with a `DesignPackageError` naming
35
+ * the file, before any write: a basename that is not a recognized shape, a
36
+ * page whose `type` is not the page's (`HomePage`, `ContactPage`), `sections`
37
+ * that cannot be located (or are not in the flow form a carry can splice), a
38
+ * section type the catalog does not carry, or a `logoCloud` whose `logos` is
39
+ * not `[]`.
19
40
  */
20
41
  export declare function readDesignHomeSeeds(dir: string, opts: {
21
42
  catalog: () => SectionLookCatalog;
43
+ page?: DesignSeedPage;
22
44
  }): HomeSeed[];
23
45
  /**
24
- * The seeds a resolved design uses (D1): its own `home/`, else — a
25
- * byte-identical copy of a shipped design IS that design — the shipped
26
- * design's, else none.
46
+ * The seeds a resolved design uses (D1): its own `home/` (or `contact/`),
47
+ * else — a byte-identical copy of a shipped design IS that design — the
48
+ * shipped design's, else none.
27
49
  */
28
50
  export declare function designHomeSeeds(resolved: ResolvedDesign, opts: {
29
51
  designsDir: string;
30
52
  catalog: () => SectionLookCatalog;
53
+ page?: DesignSeedPage;
31
54
  }): HomeSeed[];
32
55
  /** Every shipped design's seeds (D3's placeholder set reads them all). */
33
56
  export declare function shippedHomeSeeds(opts: {
34
57
  designsDir: string;
35
58
  catalog: () => SectionLookCatalog;
59
+ page?: DesignSeedPage;
36
60
  }): HomeSeed[];
37
- /** The shape's own home: its shape tree's, else the overlay's (spec § 1.4). */
61
+ /** The shape's own home (or contact page): its shape tree's, else the overlay's (spec § 1.4). */
38
62
  export declare function shapeHomePath(shape: string, opts: {
39
63
  siteTemplatesDir: string;
40
64
  templatesDir: string;
65
+ page?: DesignSeedPage;
41
66
  }): string;
67
+ /**
68
+ * A site's `siteIdentity.name` (#8661 D11, C8): the first `name:` line
69
+ * indented directly under `siteIdentity:` in `content/_site.mdx`'s front
70
+ * matter, quotes stripped. Undefined when there is no such line.
71
+ */
72
+ export declare function siteIdentityName(siteMdx: string | undefined): string | undefined;
42
73
  /**
43
74
  * A home's content fingerprint (D3): per section in order, its type and its
44
75
  * non-look `data` entries as `[key, normalized raw value]`, sorted by key.
@@ -55,9 +86,21 @@ export declare function applySeed(home: string, seed: HomeSeed, file?: string):
55
86
  /**
56
87
  * Plan a site home under a design (D3). Writes nothing: `text` is the new
57
88
  * home when the outcome is `seeded` or `restored`, and absent otherwise.
89
+ *
90
+ * `page: "contact"` (#8661 D11) plans the contact page instead. The seeds'
91
+ * `{{SITE_NAME}}` is filled with `siteName` (absent: `{Your Name}`) before
92
+ * anything is compared; the shape's own page is read with the scaffold
93
+ * markers substituted, as a scaffold installed it; the page is a placeholder
94
+ * only while its title is one too (the shape's own, or a seed's); and a write
95
+ * replaces the `title:` line as well as the sections, and the `description:`
96
+ * line while it is still a placeholder (the shape's own, or a seed's).
58
97
  */
59
98
  export declare function planDesignHome(opts: {
60
- /** The site's content/en/HomePage/home.mdx, if any. */
99
+ /** The page planned (#8661 D11). Default `"home"`. */
100
+ page?: DesignSeedPage;
101
+ /** The site's name, for a contact seed's `{{SITE_NAME}}` (#8661 D11). */
102
+ siteName?: string | undefined;
103
+ /** The site's content/en/HomePage/home.mdx (or ContactPage/contact.mdx), if any. */
61
104
  current: string | undefined;
62
105
  /** The roster's template shape. */
63
106
  shape: string | undefined;
@@ -10,17 +10,41 @@
10
10
  * fingerprint is a known placeholder (the shape's own home, or a shipped
11
11
  * design's arc of it); any authored home is left alone.
12
12
  *
13
+ * #8661 D11 — a design may also carry `contact/<shape>.mdx`, a complete
14
+ * `ContactPage` seeded the same way, with two differences: its
15
+ * `{{SITE_NAME}}` is filled from the site's `siteIdentity.name`, and it
16
+ * replaces the page's `title:` line as well as its `sections:` value (and a
17
+ * placeholder `description:` line), so the page is a placeholder only while
18
+ * its title is one too. Every reader and
19
+ * planner below takes the seeded page as `page` (default `"home"`).
20
+ *
13
21
  * Pure apart from `readDesignHomeSeeds`/`designHomeSeeds`: every directory it
14
22
  * reads is passed in (no `import.meta.url` — Jest's CJS transform).
15
23
  */
16
24
  import { existsSync, readdirSync, readFileSync } from "node:fs";
17
25
  import { join } from "node:path";
26
+ import { buildScaffoldMarkers } from "./copy.js";
18
27
  import { DesignPackageError } from "./design-package.js";
19
28
  import { locatePageSections, pageTypeOf, } from "./design-presets.js";
20
29
  import { RECOGNIZED_SHAPES } from "./parse-args.js";
30
+ import { substituteMarkers } from "./substitute.js";
21
31
  import { STARTER_DESIGNS, TemplateError } from "./template-manifest.js";
22
32
  /** Where a site's home page lives, site-relative. */
23
33
  export const HOME_PAGE_PATH = "content/en/HomePage/home.mdx";
34
+ /** Where a site's contact page lives, site-relative (#8661 D11). */
35
+ export const CONTACT_PAGE_PATH = "content/en/ContactPage/contact.mdx";
36
+ /**
37
+ * The pages a design may seed (#8661 D11), keyed by the design-package
38
+ * directory that holds their seeds (`home/<shape>.mdx`, `contact/<shape>.mdx`).
39
+ */
40
+ export const DESIGN_SEED_PAGES = {
41
+ home: { pageType: "HomePage", path: HOME_PAGE_PATH, route: "/" },
42
+ contact: { pageType: "ContactPage", path: CONTACT_PAGE_PATH, route: "/contact" },
43
+ };
44
+ /** The marker a contact seed's heading and title carry for the site's name (#8661 D11, C8). */
45
+ const SITE_NAME_MARKER = "{{SITE_NAME}}";
46
+ /** The name a contact seed takes when the site records none (#8661 D11). */
47
+ const NO_SITE_NAME = "{Your Name}";
24
48
  // ── D1: reading a design's seeds ───────────────────────────────────────────
25
49
  /** Flow punctuation: whitespace beside it is layout, never content. */
26
50
  const FLOW_PUNCTUATION = new Set(["{", "}", "[", "]", ",", ":"]);
@@ -72,14 +96,18 @@ function rawEntry(text, sections, index, key) {
72
96
  return entry === undefined ? undefined : text.slice(entry.valueStart, entry.valueEnd);
73
97
  }
74
98
  /**
75
- * Read and validate `<dir>/home/*` (D1). Refuses with a `DesignPackageError`
76
- * naming the file, before any write: a basename that is not a recognized
77
- * shape, a page whose `type` is not `HomePage`, `sections` that cannot be
78
- * located (or are not in the flow form a carry can splice), a section type
79
- * the catalog does not carry, or a `logoCloud` whose `logos` is not `[]`.
99
+ * Read and validate `<dir>/home/*` (D1), or `<dir>/contact/*` for
100
+ * `page: "contact"` (#8661 D11). Refuses with a `DesignPackageError` naming
101
+ * the file, before any write: a basename that is not a recognized shape, a
102
+ * page whose `type` is not the page's (`HomePage`, `ContactPage`), `sections`
103
+ * that cannot be located (or are not in the flow form a carry can splice), a
104
+ * section type the catalog does not carry, or a `logoCloud` whose `logos` is
105
+ * not `[]`.
80
106
  */
81
107
  export function readDesignHomeSeeds(dir, opts) {
82
- const homeDir = join(dir, "home");
108
+ const page = opts.page ?? "home";
109
+ const expectedType = DESIGN_SEED_PAGES[page].pageType;
110
+ const homeDir = join(dir, page);
83
111
  if (!existsSync(homeDir))
84
112
  return [];
85
113
  const seeds = [];
@@ -87,7 +115,7 @@ export function readDesignHomeSeeds(dir, opts) {
87
115
  const file = join(homeDir, name);
88
116
  const shape = name.replace(/\.mdx$/, "");
89
117
  if (!name.endsWith(".mdx") || !RECOGNIZED_SHAPES.includes(shape)) {
90
- throw new DesignPackageError(file, "home", `is not named after a recognized shape (expected <shape>.mdx, one of ${RECOGNIZED_SHAPES.join(", ")})`);
118
+ throw new DesignPackageError(file, page, `is not named after a recognized shape (expected <shape>.mdx, one of ${RECOGNIZED_SHAPES.join(", ")})`);
91
119
  }
92
120
  const text = readFileSync(file, "utf8");
93
121
  let pageType;
@@ -101,8 +129,8 @@ export function readDesignHomeSeeds(dir, opts) {
101
129
  throw err;
102
130
  throw new DesignPackageError(file, "sections", `cannot be located (${err.message})`);
103
131
  }
104
- if (pageType !== "HomePage") {
105
- throw new DesignPackageError(file, "type", `must be "HomePage" (got ${JSON.stringify(pageType ?? null)})`);
132
+ if (pageType !== expectedType) {
133
+ throw new DesignPackageError(file, "type", `must be "${expectedType}" (got ${JSON.stringify(pageType ?? null)})`);
106
134
  }
107
135
  if (sections === undefined || sections.some((s) => s.form !== "flow")) {
108
136
  throw new DesignPackageError(file, "sections", "must be a flow sequence of sections");
@@ -127,12 +155,12 @@ export function readDesignHomeSeeds(dir, opts) {
127
155
  return seeds;
128
156
  }
129
157
  /**
130
- * The seeds a resolved design uses (D1): its own `home/`, else — a
131
- * byte-identical copy of a shipped design IS that design — the shipped
132
- * design's, else none.
158
+ * The seeds a resolved design uses (D1): its own `home/` (or `contact/`),
159
+ * else — a byte-identical copy of a shipped design IS that design — the
160
+ * shipped design's, else none.
133
161
  */
134
162
  export function designHomeSeeds(resolved, opts) {
135
- if (existsSync(join(resolved.dir, "home")))
163
+ if (existsSync(join(resolved.dir, opts.page ?? "home")))
136
164
  return readDesignHomeSeeds(resolved.dir, opts);
137
165
  if (STARTER_DESIGNS.includes(resolved.recorded)) {
138
166
  return readDesignHomeSeeds(join(opts.designsDir, resolved.recorded), opts);
@@ -143,10 +171,87 @@ export function designHomeSeeds(resolved, opts) {
143
171
  export function shippedHomeSeeds(opts) {
144
172
  return STARTER_DESIGNS.flatMap((name) => readDesignHomeSeeds(join(opts.designsDir, name), opts));
145
173
  }
146
- /** The shape's own home: its shape tree's, else the overlay's (spec § 1.4). */
174
+ /** The shape's own home (or contact page): its shape tree's, else the overlay's (spec § 1.4). */
147
175
  export function shapeHomePath(shape, opts) {
148
- const own = join(opts.siteTemplatesDir, "shapes", shape, ...HOME_PAGE_PATH.split("/"));
149
- return existsSync(own) ? own : join(opts.templatesDir, ...HOME_PAGE_PATH.split("/"));
176
+ const path = DESIGN_SEED_PAGES[opts.page ?? "home"].path.split("/");
177
+ const own = join(opts.siteTemplatesDir, "shapes", shape, ...path);
178
+ return existsSync(own) ? own : join(opts.templatesDir, ...path);
179
+ }
180
+ // ── #8661 D11: the contact page's name and title ───────────────────────────
181
+ /** The front matter's body, or undefined when the text opens with none. */
182
+ function frontMatterOf(text) {
183
+ const fm = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*\r?$/m.exec(text);
184
+ return fm && fm.index === 0 ? fm[1] : undefined;
185
+ }
186
+ /** A one-line YAML scalar's string value: a double-quoted value is JSON-read, a single-quoted one unescaped. */
187
+ function unquote(raw) {
188
+ const value = raw.trim();
189
+ if (value.startsWith('"') && value.endsWith('"') && value.length >= 2) {
190
+ try {
191
+ return JSON.parse(value);
192
+ }
193
+ catch {
194
+ return value.slice(1, -1);
195
+ }
196
+ }
197
+ if (value.startsWith("'") && value.endsWith("'") && value.length >= 2)
198
+ return value.slice(1, -1).replace(/''/g, "'");
199
+ return value;
200
+ }
201
+ /**
202
+ * A site's `siteIdentity.name` (#8661 D11, C8): the first `name:` line
203
+ * indented directly under `siteIdentity:` in `content/_site.mdx`'s front
204
+ * matter, quotes stripped. Undefined when there is no such line.
205
+ */
206
+ export function siteIdentityName(siteMdx) {
207
+ const fm = siteMdx === undefined ? undefined : frontMatterOf(siteMdx);
208
+ if (fm === undefined)
209
+ return undefined;
210
+ const lines = fm.split(/\r?\n/);
211
+ const start = lines.findIndex((line) => /^siteIdentity:[ \t]*$/.test(line));
212
+ if (start < 0)
213
+ return undefined;
214
+ let indent;
215
+ for (const line of lines.slice(start + 1)) {
216
+ if (line.trim() === "" || line.trimStart().startsWith("#"))
217
+ continue;
218
+ const lead = line.length - line.trimStart().length;
219
+ if (lead === 0)
220
+ return undefined;
221
+ indent ??= lead;
222
+ if (lead !== indent)
223
+ continue;
224
+ const m = /^[ \t]+name:[ \t]*(.+?)[ \t]*$/.exec(line);
225
+ if (m) {
226
+ const name = unquote(m[1]);
227
+ return name === "" ? undefined : name;
228
+ }
229
+ }
230
+ return undefined;
231
+ }
232
+ /** `seed` with its `{{SITE_NAME}}` filled, escaped for the double-quoted strings it sits in. */
233
+ function fillSiteName(seed, name) {
234
+ const escaped = JSON.stringify(name).slice(1, -1);
235
+ return { ...seed, text: seed.text.split(SITE_NAME_MARKER).join(escaped) };
236
+ }
237
+ /** The `<key>:` line's span in the front matter, or undefined. */
238
+ function metaLine(text, key) {
239
+ const fm = frontMatterOf(text);
240
+ if (fm === undefined)
241
+ return undefined;
242
+ const m = new RegExp(`^${key}:[ \\t]*(.*?)[ \\t]*$`, "m").exec(fm);
243
+ if (!m)
244
+ return undefined;
245
+ const offset = text.indexOf(fm);
246
+ return { start: offset + m.index, end: offset + m.index + m[0].length, value: unquote(m[1]) };
247
+ }
248
+ /** `page` with its `<key>:` line replaced by `from`'s (or left as it is when either has none). */
249
+ function spliceMeta(page, from, key) {
250
+ const at = metaLine(page, key);
251
+ const source = metaLine(from, key);
252
+ if (at === undefined || source === undefined)
253
+ return page;
254
+ return page.slice(0, at.start) + from.slice(source.start, source.end) + page.slice(at.end);
150
255
  }
151
256
  // ── D3: the content fingerprint ────────────────────────────────────────────
152
257
  function locate(text, file) {
@@ -219,16 +324,32 @@ export function applySeed(home, seed, file = "home.mdx") {
219
324
  /**
220
325
  * Plan a site home under a design (D3). Writes nothing: `text` is the new
221
326
  * home when the outcome is `seeded` or `restored`, and absent otherwise.
327
+ *
328
+ * `page: "contact"` (#8661 D11) plans the contact page instead. The seeds'
329
+ * `{{SITE_NAME}}` is filled with `siteName` (absent: `{Your Name}`) before
330
+ * anything is compared; the shape's own page is read with the scaffold
331
+ * markers substituted, as a scaffold installed it; the page is a placeholder
332
+ * only while its title is one too (the shape's own, or a seed's); and a write
333
+ * replaces the `title:` line as well as the sections, and the `description:`
334
+ * line while it is still a placeholder (the shape's own, or a seed's).
222
335
  */
223
336
  export function planDesignHome(opts) {
224
- const { current, shape, target, shapeHome, catalog } = opts;
337
+ const page = opts.page ?? "home";
338
+ const contact = page === "contact";
339
+ const pagePath = DESIGN_SEED_PAGES[page].path;
340
+ const { current, shape, catalog } = opts;
225
341
  if (current === undefined)
226
342
  return { outcome: "no-home" };
227
343
  if (shape === undefined)
228
344
  return { outcome: "no-shape" };
345
+ const name = opts.siteName ?? NO_SITE_NAME;
346
+ const fill = (seed) => (contact ? fillSiteName(seed, name) : seed);
347
+ const target = opts.target === undefined ? undefined : fill(opts.target);
348
+ // The scaffold's own markers carry no project-specific value a contact page uses.
349
+ const shapeHome = contact ? substituteMarkers(opts.shapeHome, buildScaffoldMarkers("")) : opts.shapeHome;
229
350
  let currentPrint;
230
351
  try {
231
- currentPrint = fingerprint(current, catalog, HOME_PAGE_PATH);
352
+ currentPrint = fingerprint(current, catalog, pagePath);
232
353
  }
233
354
  catch (err) {
234
355
  // A home whose sections cannot be read is not a placeholder: never write it.
@@ -236,21 +357,38 @@ export function planDesignHome(opts) {
236
357
  return { outcome: "authored" };
237
358
  throw err;
238
359
  }
239
- const seeds = [...opts.shippedSeeds.filter((s) => s.shape === shape), ...(target !== undefined ? [target] : [])];
360
+ const seeds = [
361
+ ...opts.shippedSeeds.filter((s) => s.shape === shape).map(fill),
362
+ ...(target !== undefined ? [target] : []),
363
+ ];
240
364
  const placeholders = new Set([
241
365
  fingerprint(shapeHome, catalog),
242
366
  ...seeds.map((seed) => fingerprint(spliceSections(shapeHome, applySeed(shapeHome, seed), "shape home"), catalog)),
243
367
  ]);
244
368
  if (!placeholders.has(currentPrint))
245
369
  return { outcome: "authored" };
370
+ // #8661 D11 — a contact page whose title was retitled is authored, whatever its sections.
371
+ const placeholderTexts = [shapeHome, ...seeds.map((seed) => seed.text)];
372
+ const placeholderMeta = (key) => new Set(placeholderTexts.map((text) => metaLine(text, key)?.value));
373
+ if (contact && !placeholderMeta("title").has(metaLine(current, "title")?.value))
374
+ return { outcome: "authored" };
246
375
  const wanted = target !== undefined
247
- ? applySeed(current, target, HOME_PAGE_PATH)
376
+ ? applySeed(current, target, pagePath)
248
377
  : (() => {
249
378
  const own = locate(shapeHome, "shape home");
250
379
  return shapeHome.slice(own.valueStart, own.valueEnd);
251
380
  })();
252
- const text = spliceSections(current, wanted, HOME_PAGE_PATH);
253
- if (fingerprint(text, catalog) === currentPrint)
381
+ let text = spliceSections(current, wanted, pagePath);
382
+ if (contact) {
383
+ const from = target?.text ?? shapeHome;
384
+ text = spliceMeta(text, from, "title");
385
+ // An edited description is the customer's: only a placeholder one is replaced.
386
+ if (placeholderMeta("description").has(metaLine(current, "description")?.value)) {
387
+ text = spliceMeta(text, from, "description");
388
+ }
389
+ }
390
+ const sameMeta = ["title", "description"].every((key) => metaLine(text, key)?.value === metaLine(current, key)?.value);
391
+ if (fingerprint(text, catalog) === currentPrint && sameMeta)
254
392
  return { outcome: "unchanged" };
255
393
  return { outcome: target !== undefined ? "seeded" : "restored", text };
256
394
  }
@@ -54,9 +54,14 @@ export type JsonLdDriftVerdict = {
54
54
  * returned as it is.
55
55
  */
56
56
  export declare function admitSeededPeopleSlide(before: ComposedPages, after: ComposedPages): ComposedPages;
57
+ /**
58
+ * `after` with the standard contact page put back when the seeded one differs
59
+ * only in `name` and `description` (#8661 D11).
60
+ */
61
+ export declare function admitSeededContactPage(before: ComposedPages, after: ComposedPages): ComposedPages;
57
62
  /**
58
63
  * Decide whether `apply-design <design>` left every page's JSON-LD unchanged
59
- * (logo excluded), the seeded people slide's Persons admitted.
64
+ * (logo excluded), the seeded people slide's Persons and contact page admitted.
60
65
  */
61
66
  export declare function assessJsonLdDrift(design: string, before: ComposedPages, after: ComposedPages): JsonLdDriftVerdict;
62
67
  export interface MeasureApplyDesignDriftOptions {
@@ -21,11 +21,14 @@
21
21
  * organization home's people slide adds one `Person` per seeded team member to
22
22
  * the home's graph. `admitSeededPeopleSlide` puts the standard home back only
23
23
  * when the seeded home is exactly that, so any other change still counts.
24
+ * Likewise a design that seeds the contact page renames and re-describes it
25
+ * (#8661 D11); `admitSeededContactPage` admits only those two fields.
24
26
  */
25
27
  import { execFileSync } from "node:child_process";
26
28
  import { writeFileSync } from "node:fs";
27
29
  import { join } from "node:path";
28
30
  import { isDeepStrictEqual } from "node:util";
31
+ import { CONTACT_PAGE_PATH } from "../design-home.js";
29
32
  import { TEAM_SEED_MEMBERS } from "../team-profiles.js";
30
33
  function describePair(row) {
31
34
  const measured = row.status === "unmeasurable" || row.ratio === null
@@ -140,18 +143,36 @@ export function admitSeededPeopleSlide(before, after) {
140
143
  const isPeopleSlide = isDeepStrictEqual(page, JSON.parse(standard.jsonld)) && isDeepStrictEqual(people, expected);
141
144
  return isPeopleSlide ? { ...after, [HOME_PAGE]: standard } : after;
142
145
  }
146
+ /**
147
+ * `after` with the standard contact page put back when the seeded one differs
148
+ * only in `name` and `description` (#8661 D11).
149
+ */
150
+ export function admitSeededContactPage(before, after) {
151
+ const standard = before[CONTACT_PAGE_PATH];
152
+ const seeded = after[CONTACT_PAGE_PATH];
153
+ if (standard === undefined || seeded === undefined || !seeded.sectionsValid)
154
+ return after;
155
+ const strip = (jsonld) => ({
156
+ ...JSON.parse(jsonld),
157
+ name: undefined,
158
+ description: undefined,
159
+ });
160
+ return isDeepStrictEqual(strip(seeded.jsonld), strip(standard.jsonld))
161
+ ? { ...after, [CONTACT_PAGE_PATH]: standard }
162
+ : after;
163
+ }
143
164
  /** How many changed nodes a drift reason lists before it stops. */
144
165
  const REASON_NODE_LIMIT = 10;
145
166
  /**
146
167
  * Decide whether `apply-design <design>` left every page's JSON-LD unchanged
147
- * (logo excluded), the seeded people slide's Persons admitted.
168
+ * (logo excluded), the seeded people slide's Persons and contact page admitted.
148
169
  */
149
170
  export function assessJsonLdDrift(design, before, after) {
150
171
  const pages = Object.keys(before).length;
151
172
  if (pages === 0) {
152
173
  return { ok: false, pages, changed: [], reason: `design ${design}: no page was composed` };
153
174
  }
154
- const changed = jsonLdDrift(before, admitSeededPeopleSlide(before, after));
175
+ const changed = jsonLdDrift(before, admitSeededContactPage(before, admitSeededPeopleSlide(before, after)));
155
176
  if (changed.length === 0)
156
177
  return { ok: true, pages };
157
178
  const listed = changed