create-ailk 0.39.0 → 0.40.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 (187) hide show
  1. package/dist/add-route.js +15 -0
  2. package/dist/body-heading.d.ts +2 -1
  3. package/dist/body-heading.js +31 -3
  4. package/dist/module-architecture.js +0 -3
  5. package/dist/remove-module.js +13 -4
  6. package/dist/routes.d.ts +7 -0
  7. package/dist/routes.js +1 -1
  8. package/dist/site-roster.js +7 -1
  9. package/dist/surfaces.d.ts +2 -0
  10. package/dist/surfaces.js +59 -172
  11. package/package.json +3 -3
  12. package/templates/apps/web/CLAUDE.md +7 -1
  13. package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +3 -2
  14. package/templates/apps/web/__tests__/__mocks__/next-intl.ts +3 -2
  15. package/templates/apps/web/app/[locale]/layout.tsx +1 -1
  16. package/templates/apps/web/i18n/request.ts +5 -1
  17. package/templates/apps/web/jest.config.cjs +6 -0
  18. package/templates/apps/web/lib/__tests__/deck-page.test.ts +9 -0
  19. package/templates/apps/web/lib/__tests__/in-page-magnet-self-request.test.ts +1 -1
  20. package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +2 -2
  21. package/templates/apps/web/lib/__tests__/pricing-page.test.ts +1 -1
  22. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
  23. package/templates/apps/web/lib/in-page-magnet.ts +2 -2
  24. package/templates/apps/web/lib/pricing-page.ts +3 -3
  25. package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +1 -1
  26. package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +1 -1
  27. package/templates/apps/web/lib/site-header.ts +1 -1
  28. package/templates/apps/web/messages/en.json +0 -119
  29. package/templates/apps/web/next.config.mjs +7 -0
  30. package/templates/apps/web/package.json +1 -0
  31. package/templates/apps/web/site-pages.config.tsx +85 -0
  32. package/templates/tools/body-heading.ts +30 -3
  33. package/versions.json +50 -49
  34. package/templates/apps/web/app/[locale]/(authed)/leads/__tests__/page.test.tsx +0 -205
  35. package/templates/apps/web/app/[locale]/(authed)/leads/components/LeadsTable.tsx +0 -137
  36. package/templates/apps/web/app/[locale]/(authed)/leads/page.tsx +0 -122
  37. package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ForbiddenState.tsx +0 -24
  38. package/templates/apps/web/app/[locale]/(authed)/waitlist/format.ts +0 -111
  39. package/templates/apps/web/app/[locale]/[slug]/[detail]/__tests__/page.test.tsx +0 -402
  40. package/templates/apps/web/app/[locale]/[slug]/[detail]/page.tsx +0 -143
  41. package/templates/apps/web/app/[locale]/[slug]/__tests__/page.test.tsx +0 -148
  42. package/templates/apps/web/app/[locale]/[slug]/page.tsx +0 -109
  43. package/templates/apps/web/app/[locale]/about/[slug]/page.tsx +0 -46
  44. package/templates/apps/web/app/[locale]/about/__tests__/about-routes.test.tsx +0 -353
  45. package/templates/apps/web/app/[locale]/about/page.tsx +0 -122
  46. package/templates/apps/web/app/[locale]/alternatives/__tests__/page.test.tsx +0 -161
  47. package/templates/apps/web/app/[locale]/alternatives/page.tsx +0 -112
  48. package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +0 -244
  49. package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +0 -325
  50. package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +0 -120
  51. package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +0 -73
  52. package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +0 -497
  53. package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +0 -172
  54. package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +0 -153
  55. package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +0 -141
  56. package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +0 -546
  57. package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +0 -189
  58. package/templates/apps/web/app/[locale]/careers/page.tsx +0 -165
  59. package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +0 -49
  60. package/templates/apps/web/app/[locale]/case-studies/__tests__/hub-children.test.tsx +0 -65
  61. package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +0 -125
  62. package/templates/apps/web/app/[locale]/case-studies/page.tsx +0 -49
  63. package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +0 -85
  64. package/templates/apps/web/app/[locale]/clients/page.tsx +0 -47
  65. package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +0 -249
  66. package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +0 -400
  67. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-magnet.test.ts +0 -138
  68. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-text.test.ts +0 -49
  69. package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +0 -494
  70. package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +0 -1122
  71. package/templates/apps/web/app/[locale]/contact/__tests__/intake-analytics.test.ts +0 -51
  72. package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +0 -319
  73. package/templates/apps/web/app/[locale]/contact/contact-form-magnet.ts +0 -77
  74. package/templates/apps/web/app/[locale]/contact/contact-form-text.ts +0 -52
  75. package/templates/apps/web/app/[locale]/contact/contact.actions.ts +0 -403
  76. package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +0 -49
  77. package/templates/apps/web/app/[locale]/contact/intake-script.ts +0 -92
  78. package/templates/apps/web/app/[locale]/contact/page.tsx +0 -267
  79. package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +0 -50
  80. package/templates/apps/web/app/[locale]/courses/__tests__/hub-children.test.tsx +0 -32
  81. package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +0 -123
  82. package/templates/apps/web/app/[locale]/courses/page.tsx +0 -49
  83. package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +0 -57
  84. package/templates/apps/web/app/[locale]/events/__tests__/hub-children.test.tsx +0 -32
  85. package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +0 -164
  86. package/templates/apps/web/app/[locale]/events/__tests__/program-event.test.tsx +0 -120
  87. package/templates/apps/web/app/[locale]/events/page.tsx +0 -60
  88. package/templates/apps/web/app/[locale]/faq/page.tsx +0 -54
  89. package/templates/apps/web/app/[locale]/features/[slug]/page.tsx +0 -54
  90. package/templates/apps/web/app/[locale]/features/__tests__/hub-children.test.tsx +0 -32
  91. package/templates/apps/web/app/[locale]/features/page.tsx +0 -50
  92. package/templates/apps/web/app/[locale]/for/[slug]/page.tsx +0 -54
  93. package/templates/apps/web/app/[locale]/for/__tests__/hub-children.test.tsx +0 -32
  94. package/templates/apps/web/app/[locale]/for/__tests__/page-renderer-migration.test.tsx +0 -90
  95. package/templates/apps/web/app/[locale]/for/page.tsx +0 -51
  96. package/templates/apps/web/app/[locale]/glossary/page.tsx +0 -53
  97. package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +0 -50
  98. package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +0 -78
  99. package/templates/apps/web/app/[locale]/how-to/page.tsx +0 -50
  100. package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +0 -54
  101. package/templates/apps/web/app/[locale]/integrations/__tests__/hub-children.test.tsx +0 -38
  102. package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +0 -141
  103. package/templates/apps/web/app/[locale]/integrations/page.tsx +0 -49
  104. package/templates/apps/web/app/[locale]/launch-service/page.tsx +0 -44
  105. package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +0 -236
  106. package/templates/apps/web/app/[locale]/newsletter/page.tsx +0 -179
  107. package/templates/apps/web/app/[locale]/page.tsx +0 -147
  108. package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +0 -45
  109. package/templates/apps/web/app/[locale]/partners/__tests__/hub-children.test.tsx +0 -32
  110. package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +0 -125
  111. package/templates/apps/web/app/[locale]/partners/page.tsx +0 -49
  112. package/templates/apps/web/app/[locale]/portfolio/[slug]/page.tsx +0 -46
  113. package/templates/apps/web/app/[locale]/portfolio/__tests__/hub-children.test.tsx +0 -38
  114. package/templates/apps/web/app/[locale]/portfolio/page.tsx +0 -50
  115. package/templates/apps/web/app/[locale]/pricing/[slug]/__tests__/page.test.tsx +0 -324
  116. package/templates/apps/web/app/[locale]/pricing/[slug]/page.tsx +0 -87
  117. package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +0 -7
  118. package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +0 -605
  119. package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +0 -219
  120. package/templates/apps/web/app/[locale]/pricing/__tests__/pricing-pages.test.tsx +0 -215
  121. package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +0 -282
  122. package/templates/apps/web/app/[locale]/pricing/page.tsx +0 -120
  123. package/templates/apps/web/app/[locale]/privacy/page.tsx +0 -40
  124. package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +0 -50
  125. package/templates/apps/web/app/[locale]/products/__tests__/hub-children.test.tsx +0 -32
  126. package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +0 -141
  127. package/templates/apps/web/app/[locale]/products/page.tsx +0 -49
  128. package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +0 -37
  129. package/templates/apps/web/app/[locale]/projects/__tests__/hub-children.test.tsx +0 -32
  130. package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +0 -157
  131. package/templates/apps/web/app/[locale]/projects/page.tsx +0 -49
  132. package/templates/apps/web/app/[locale]/purchase-policy/page.tsx +0 -49
  133. package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +0 -54
  134. package/templates/apps/web/app/[locale]/resources/__tests__/hub-children.test.tsx +0 -38
  135. package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +0 -151
  136. package/templates/apps/web/app/[locale]/resources/page.tsx +0 -49
  137. package/templates/apps/web/app/[locale]/services/[slug]/[child]/page.tsx +0 -68
  138. package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +0 -88
  139. package/templates/apps/web/app/[locale]/services/__tests__/hub-children.test.tsx +0 -158
  140. package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +0 -187
  141. package/templates/apps/web/app/[locale]/services/__tests__/service-detail-sections.test.tsx +0 -224
  142. package/templates/apps/web/app/[locale]/services/__tests__/service-families.test.tsx +0 -368
  143. package/templates/apps/web/app/[locale]/services/page.tsx +0 -71
  144. package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +0 -49
  145. package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +0 -81
  146. package/templates/apps/web/app/[locale]/software/page.tsx +0 -49
  147. package/templates/apps/web/app/[locale]/team/[slug]/page.tsx +0 -45
  148. package/templates/apps/web/app/[locale]/team/__tests__/hub-children.test.tsx +0 -32
  149. package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +0 -161
  150. package/templates/apps/web/app/[locale]/team/page.tsx +0 -50
  151. package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +0 -54
  152. package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +0 -82
  153. package/templates/apps/web/app/[locale]/tech-articles/page.tsx +0 -49
  154. package/templates/apps/web/app/[locale]/templates/[slug]/__tests__/page.test.tsx +0 -203
  155. package/templates/apps/web/app/[locale]/templates/[slug]/page.tsx +0 -81
  156. package/templates/apps/web/app/[locale]/templates/__tests__/page.test.tsx +0 -237
  157. package/templates/apps/web/app/[locale]/templates/page.tsx +0 -114
  158. package/templates/apps/web/app/[locale]/terms/page.tsx +0 -40
  159. package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +0 -85
  160. package/templates/apps/web/app/[locale]/testimonials/page.tsx +0 -51
  161. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +0 -136
  162. package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +0 -39
  163. package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +0 -226
  164. package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +0 -217
  165. package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +0 -106
  166. package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +0 -94
  167. package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe.actions.ts +0 -55
  168. package/templates/apps/web/app/[locale]/vs/[slug]/__tests__/page.test.tsx +0 -100
  169. package/templates/apps/web/app/[locale]/vs/[slug]/page.tsx +0 -60
  170. package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +0 -54
  171. package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +0 -82
  172. package/templates/apps/web/app/[locale]/whitepapers/page.tsx +0 -49
  173. package/templates/apps/web/app/[locale]/working-agreement/__tests__/page.test.tsx +0 -63
  174. package/templates/apps/web/app/[locale]/working-agreement/page.tsx +0 -41
  175. package/templates/apps/web/lib/__tests__/hub-children.fixtures.ts +0 -279
  176. package/templates/apps/web/lib/__tests__/route-family.test.ts +0 -57
  177. package/templates/apps/web/lib/__tests__/service-listing.test.ts +0 -111
  178. package/templates/apps/web/lib/__tests__/template-listing.test.ts +0 -158
  179. package/templates/apps/web/lib/hub-children.tsx +0 -351
  180. package/templates/apps/web/lib/meet-placeholder.ts +0 -5
  181. package/templates/apps/web/lib/posting-title.ts +0 -39
  182. package/templates/apps/web/lib/route-family.ts +0 -69
  183. package/templates/apps/web/lib/service-listing.ts +0 -89
  184. package/templates/apps/web/lib/template-listing.ts +0 -169
  185. package/templates/apps/web/src/lib/__tests__/lead-write.test.ts +0 -187
  186. package/templates/apps/web/src/lib/lead-write.ts +0 -90
  187. /package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +0 -0
@@ -1,267 +0,0 @@
1
- // Contact page (#6730 D8). Renders sections via renderPage (sections mode)
2
- // and places ONE contact surface, first match wins: into the page's first
3
- // `contact-form` section; else into a leading split hero's right column;
4
- // else after the page.
5
- //
6
- // That surface is the shared `LeadCaptureForm` block, bound to
7
- // `captureLeadAction` — unless the API says this deployment accepts no
8
- // contact message (production with neither a database nor an email key), in
9
- // which case it is `ContactFallback`: the site's contact email, never a form
10
- // that would report a message as sent when it reached nobody. An unreachable
11
- // API, an older API without the status route, or any other failed read is
12
- // treated as accepting: the form renders, and its submit reports honestly.
13
- //
14
- // The form (#8661 D6, #8847 D7), first usable wins: the workspace's Contact
15
- // form magnet (`flows.get("contact")`, the public flow read — the API
16
- // resolves the workspace, the site alias keyless and a spoke by its key);
17
- // else the page's `contact-form` section fields when it declares any; else
18
- // the built-in form: the seeded magnet's own config, its name, email and
19
- // message labels from the `contact` catalog. Every visible fact on the page
20
- // comes from the magnet (#8847): its field step's title is the page's H1 and
21
- // `<title>`, its body the line under it (`framedSources`), and its ending
22
- // the success message. The built-in config stands in when the hub cannot be
23
- // read, so a fresh deploy looks the same either way. The section's own
24
- // `successMessage` and `submitLabel` apply only when its own fields are
25
- // used. A magnet-driven post is stamped `source: "flow:contact"`, so it is
26
- // an Inbox submission of the Contact form; the other two post as
27
- // `contact-form` (#8747). The page is rendered on every request, but its two
28
- // hub reads (the magnet and the capture status) are shared across requests
29
- // for HUB_READ_TTL_MS (`lib/in-page-magnet.ts`, #8731). The terms statement
30
- // links Terms and Privacy Policy from a page-built map — a magnet label can
31
- // name a link key, never an href. Under the form, "Prefer email?" and the
32
- // `_site.mdx` contact email, when the site has one.
33
- //
34
- // A `contact-form` section in the `column` variant (the minimalism Contact
35
- // page, #8661 D12) gets the stacked form look and a Send that stays enabled,
36
- // gating the terms box on submit instead.
37
- //
38
- // The chat-style intake (ConversationalIntakeWrapper, #4534) remains
39
- // available to a site that prefers it. JSON-LD and translations handled by
40
- // renderPage.
41
- import type {
42
- getMdxSource as defaultGetMdxSource,
43
- getPageSections as defaultGetPageSections,
44
- } from "@working-theory/page-renderer";
45
- import {
46
- getMdxSource as loadMdxSource,
47
- getPageSections as loadPageSections,
48
- renderPage,
49
- renderPageMetadata,
50
- } from "@working-theory/page-renderer";
51
- import {
52
- ContactFallback,
53
- type ContactFormField,
54
- LeadCaptureForm,
55
- type LeadCaptureFormText,
56
- localeHref,
57
- } from "@working-theory/ui";
58
- import { Link, Text } from "@working-theory/ui/primitives";
59
- import {
60
- CONTACT_FORM_FLOW_SLUG,
61
- contactFormFlowConfig,
62
- flowLeadSource,
63
- } from "@working-theory/validation";
64
- import type { Metadata } from "next";
65
- import { getTranslations } from "next-intl/server";
66
- import type { ReactElement } from "react";
67
-
68
- import {
69
- framedSources,
70
- inPageView,
71
- readCaptureStatus,
72
- readServedMagnet,
73
- type InPageView,
74
- } from "../../../lib/in-page-magnet";
75
-
76
- import { contactFormFromConfig, type ContactFormView } from "./contact-form-magnet";
77
- import { contactFormText } from "./contact-form-text";
78
- import { captureLeadAction } from "./contact.actions";
79
- import { readSiteContactEmail } from "./site-contact-email";
80
-
81
- // #8661 D6 — rendered on every request; the magnet read behind it is shared for HUB_READ_TTL_MS (#8731, lib/in-page-magnet.ts).
82
- export const dynamic = "force-dynamic";
83
-
84
- interface Props {
85
- params: Promise<{ locale: string }>;
86
- getMdxSource?: typeof defaultGetMdxSource;
87
- getPageSections?: typeof defaultGetPageSections;
88
- }
89
-
90
- type Section = Awaited<ReturnType<typeof defaultGetPageSections>>[number];
91
- type ContactFormSection = Extract<Section, { type: "contact-form" }>;
92
-
93
- const FIELD_TYPES = ["text", "email", "tel", "textarea", "select"] as const;
94
-
95
- /** A `contact-form` section's declared fields, as the form block renders them. */
96
- function sectionFields(section: ContactFormSection): ContactFormField[] {
97
- return section.data.fields.map((f) => ({
98
- name: f.name,
99
- label: f.label,
100
- type: (FIELD_TYPES as readonly string[]).includes(f.type)
101
- ? (f.type as (typeof FIELD_TYPES)[number])
102
- : "text",
103
- ...(f.required !== undefined ? { required: f.required } : {}),
104
- ...(f.placeholder !== undefined ? { placeholder: f.placeholder } : {}),
105
- ...(f.options !== undefined ? { options: f.options } : {}),
106
- ...(f.colSpan !== undefined ? { colSpan: f.colSpan as 1 | 2 } : {}),
107
- }));
108
- }
109
-
110
- const BUILT_IN_LABELS = { name: "nameLabel", email: "emailLabel", message: "messageLabel" } as const;
111
-
112
- /**
113
- * The built-in form: the seeded magnet's own fields, with the labels the
114
- * `contact` catalog carries (name, email, message) taken from it, so a
115
- * translated site keeps its translated form when the magnet is absent.
116
- */
117
- function builtInFields(text: LeadCaptureFormText, locale: string): ContactFormField[] {
118
- const view = contactFormFromConfig(contactFormFlowConfig, locale);
119
- return (view?.fields ?? []).map((f) => {
120
- const key = BUILT_IN_LABELS[f.name as keyof typeof BUILT_IN_LABELS];
121
- return key ? { ...f, label: text[key] } : f;
122
- });
123
- }
124
-
125
- /**
126
- * The page's view of the Contact form (#8847 D7): the served magnet's when it
127
- * maps, else the built-in config's. `served` says which.
128
- */
129
- async function contactView(
130
- locale: string,
131
- fallbackHeadline: string,
132
- ): Promise<{ view: InPageView; served: boolean }> {
133
- const magnet = await readServedMagnet(CONTACT_FORM_FLOW_SLUG);
134
- const served = magnet ? inPageView(magnet, locale, "contact", fallbackHeadline) : null;
135
- if (served) return { view: served, served: true };
136
- // The built-in config always maps: its first step has name and email.
137
- return {
138
- view: inPageView(contactFormFlowConfig, locale, "contact", fallbackHeadline)!,
139
- served: false,
140
- };
141
- }
142
-
143
- export async function generateMetadata({
144
- params,
145
- getMdxSource,
146
- getPageSections,
147
- }: Props): Promise<Metadata> {
148
- const { locale } = await params;
149
- const t = await getTranslations({ locale, namespace: "contact" });
150
- const { view } = await contactView(locale, t("successMessage"));
151
- // #8847 D7 — the `<title>` is the magnet's step title, like the H1.
152
- const framed = framedSources({
153
- getMdxSource: getMdxSource ?? loadMdxSource,
154
- getPageSections: getPageSections ?? loadPageSections,
155
- view,
156
- });
157
- return renderPageMetadata({
158
- type: "ContactPage",
159
- slug: "contact",
160
- locale,
161
- getMdxSource: framed.getMdxSource,
162
- });
163
- }
164
-
165
- export default async function Page({
166
- params,
167
- getMdxSource,
168
- getPageSections,
169
- }: Props): Promise<ReactElement> {
170
- const { locale } = await params;
171
- const [status, t] = await Promise.all([
172
- readCaptureStatus(),
173
- getTranslations({ locale, namespace: "contact" }),
174
- ]);
175
- const accepting = status?.contact ?? true;
176
- const contactEmail = readSiteContactEmail();
177
- const text = contactFormText(t);
178
- const { view, served } = await contactView(locale, text.success);
179
- const framed = framedSources({
180
- getMdxSource: getMdxSource ?? loadMdxSource,
181
- getPageSections: getPageSections ?? loadPageSections,
182
- view,
183
- });
184
-
185
- const source = await framed.getMdxSource("ContactPage", "contact", locale);
186
- const sections = source ? await framed.getPageSections(source.frontmatter) : [];
187
- const formSection = sections.find(
188
- (s): s is ContactFormSection => s.type === "contact-form",
189
- );
190
- // The section's own published address stands in when _site.mdx has none.
191
- const fallbackEmail = contactEmail ?? formSection?.data.contactInfo?.email;
192
- const lead = sections[0];
193
- const slotted =
194
- formSection?.id ??
195
- (lead?.type === "hero" && lead.data.variant === "split" ? lead.id : undefined);
196
-
197
- // #8661 D6 — the magnet's fields, else the section's, else the built-in form.
198
- const form = view.form as ContactFormView;
199
- const declared =
200
- !served && formSection && formSection.data.fields.length > 0 ? formSection : undefined;
201
- const fields: ContactFormField[] = served
202
- ? form.fields
203
- : declared
204
- ? sectionFields(declared)
205
- : builtInFields(text, locale);
206
- // #8847 D7 — the section's submit label and success message apply only to
207
- // its own fields; otherwise the magnet's (or the built-in config's) ending.
208
- const submitLabel = served ? form.submitLabel : declared?.data.submitLabel;
209
- const column = formSection?.data.variant === "column";
210
-
211
- const leadForm = accepting ? (
212
- <LeadCaptureForm
213
- action={captureLeadAction}
214
- text={served && form.consentStatement ? { ...text, consentStatement: form.consentStatement } : text}
215
- termsHref={localeHref(locale, "/terms")}
216
- policies={{
217
- terms: localeHref(locale, "/terms"),
218
- privacy: localeHref(locale, "/privacy"),
219
- working_agreement: localeHref(locale, "/working-agreement"),
220
- }}
221
- fallbackEmail={fallbackEmail}
222
- fields={fields}
223
- submitLabel={submitLabel}
224
- {...(declared ? { successMessage: declared.data.successMessage } : { ending: view.ending })}
225
- {...(served && { source: flowLeadSource(CONTACT_FORM_FLOW_SLUG) })}
226
- {...(column && { look: "column" as const, consentGate: "on-submit" as const })}
227
- />
228
- ) : (
229
- <ContactFallback
230
- email={fallbackEmail}
231
- text={{
232
- heading: text.unavailableHeading,
233
- body: text.unavailableBody,
234
- noEmail: text.unavailableNoEmail,
235
- }}
236
- />
237
- );
238
- // #8847 D7 — one muted line under the form; absent with no address.
239
- const surface = (
240
- <>
241
- {leadForm}
242
- {contactEmail !== undefined && (
243
- <div className="mt-block-tight text-center" data-testid="contact-prefer-email">
244
- <Text tone="muted" variant="body-sm">
245
- {t("preferEmail")} <Link href={`mailto:${contactEmail}`}>{contactEmail}</Link>
246
- </Text>
247
- </div>
248
- )}
249
- </>
250
- );
251
-
252
- const rendered = await renderPage({
253
- type: "ContactPage",
254
- slug: "contact",
255
- locale,
256
- translationsNamespace: "contact",
257
- getMdxSource: framed.getMdxSource,
258
- getPageSections: framed.getPageSections,
259
- ...(slotted !== undefined && { sectionSlots: { [slotted]: surface } }),
260
- });
261
- return (
262
- <>
263
- {rendered}
264
- {slotted === undefined ? surface : null}
265
- </>
266
- );
267
- }
@@ -1,50 +0,0 @@
1
- // Course detail page. Reads the Course MDX for the given slug, renders via
2
- // @working-theory/page-renderer, and emits a JSON-LD <script>. Unknown slugs trigger 404.
3
- import type { getMdxSource as defaultGetMdxSource } from "@working-theory/page-renderer";
4
- import {
5
- getMdxSource as loadMdxSource,
6
- renderPage,
7
- renderPageMetadata,
8
- } from "@working-theory/page-renderer";
9
- import type { Metadata } from "next";
10
- import type { ReactElement } from "react";
11
-
12
- interface Props {
13
- params: Promise<{ locale: string; slug: string }>;
14
- getMdxSource?: typeof defaultGetMdxSource;
15
- }
16
-
17
- export async function generateMetadata({
18
- params,
19
- }: Pick<Props, "params">): Promise<Metadata> {
20
- const { locale, slug } = await params;
21
- return renderPageMetadata({ type: "Course", slug, locale });
22
- }
23
-
24
- export default async function Page({
25
- params,
26
- getMdxSource,
27
- }: Props): Promise<ReactElement> {
28
- const { locale, slug } = await params;
29
- // A page that composes `sections[]` renders them (JSON-LD is built from
30
- // the same sections); a prose page renders its MDX body — the rule
31
- // /vs/[slug] applies (#10122).
32
- const source = await (getMdxSource ?? loadMdxSource)("Course", slug, locale);
33
- const composed =
34
- source !== null &&
35
- Array.isArray((source.frontmatter as { sections?: unknown[] }).sections) &&
36
- ((source.frontmatter as { sections?: unknown[] }).sections?.length ?? 0) >
37
- 0;
38
- return renderPage({
39
- type: "Course",
40
- slug,
41
- locale,
42
- ...(composed
43
- ? {}
44
- : {
45
- bodyMode: "mdx-body" as const,
46
- populatedDescriptionTestId: "course-description",
47
- }),
48
- ...(getMdxSource !== undefined && { getMdxSource }),
49
- });
50
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * Hub child cards (#10121) for /courses. The shared cases live in
3
- * `lib/__tests__/hub-children.fixtures.ts`; this file sits beside the route so
4
- * a scaffold without /courses drops it with the route (#10157).
5
- */
6
- const mockRenderPage = jest.fn(async (..._args: unknown[]) => "<rendered/>");
7
-
8
- jest.mock("@working-theory/page-renderer", () => ({
9
- __esModule: true,
10
- renderPage: (...args: unknown[]) => mockRenderPage(...args),
11
- renderPageMetadata: jest.fn(),
12
- // Never reached — every call in this suite passes its loaders via DI.
13
- getMdxSlugs: jest.fn(),
14
- getMdxSource: jest.fn(),
15
- getPageSections: jest.fn(),
16
- }));
17
-
18
- jest.mock("@working-theory/ui/sections", () => ({
19
- __esModule: true,
20
- SectionRenderer: () => null,
21
- }));
22
-
23
- import CoursesPage from "../page";
24
- import {
25
- describeHub,
26
- type HubPage,
27
- } from "../../../../lib/__tests__/hub-children.fixtures";
28
-
29
- describeHub(
30
- ["courses", CoursesPage as HubPage, "CoursesList", "Course", "mdx-body"],
31
- mockRenderPage,
32
- );
@@ -1,123 +0,0 @@
1
- /**
2
- * HTML snapshot regression tests for courses routes — @working-theory/page-renderer migration.
3
- *
4
- * Node version: captured against Node 22.x (same as CI).
5
- * MDX seed content: DI-injected stub — no fs reads, deterministic.
6
- *
7
- * Two-commit strategy:
8
- * Commit 1: this file added; snapshots captured against pre-migration routes.
9
- * Commit 2: routes migrated; same snapshots verify diff=0.
10
- *
11
- * Routes covered:
12
- * - courses/page (empty: no CoursesList MDX)
13
- * - courses/page (populated: CoursesList MDX present)
14
- * - courses/[slug] (populated: populated state)
15
- * - courses/[slug] (notFound: unknown slug triggers notFound())
16
- *
17
- * Failure = snapshot diff > 0 bytes. DO NOT regenerate snapshots to pass.
18
- * A non-zero diff indicates a behavior regression in the migration. Escalate.
19
- */
20
- import React from "react";
21
- import { render } from "@testing-library/react";
22
-
23
- jest.mock("next-mdx-remote/rsc", () => ({
24
- __esModule: true,
25
- MDXRemote: ({ source }: { source: string }): React.ReactElement =>
26
- React.createElement("div", { "data-testid": "mdx-rendered" }, source),
27
- }));
28
-
29
- jest.mock("next/navigation", () => ({
30
- __esModule: true,
31
- notFound: jest.fn(() => {
32
- throw new Error("NEXT_NOT_FOUND");
33
- }),
34
- }));
35
-
36
- import CoursesPage from "../page";
37
- import CourseSlugPage from "../[slug]/page";
38
- import { notFound } from "next/navigation";
39
-
40
- const mockNotFound = notFound as jest.MockedFunction<typeof notFound>;
41
-
42
- describe("courses/page — snapshot regression", () => {
43
- it("empty state renders deterministic HTML", async () => {
44
- const getMdxSource = jest.fn().mockResolvedValue(null);
45
-
46
- const element = await CoursesPage({
47
- params: Promise.resolve({ locale: "en" }),
48
- // No child pages: this snapshot pins the hub's own render (#10121).
49
- getMdxSlugs: async () => [],
50
- getMdxSource,
51
- });
52
- const { container } = render(element);
53
- expect(container.innerHTML).toMatchInlineSnapshot(
54
- `"<main id="main"><h1 class="text-heading-1 lg:text-display-sm font-display text-fg hero-type-display">Courses</h1><p data-testid="section-empty-state">Courses listing coming soon.</p></main>"`,
55
- );
56
- });
57
-
58
- it("populated state renders deterministic HTML", async () => {
59
- const getMdxSource = jest.fn().mockResolvedValue({
60
- frontmatter: {
61
- type: "CoursesList" as const,
62
- slug: "courses",
63
- title: "Courses",
64
- description: "Structured learning paths for teams adopting AILK.",
65
- },
66
- body: "## Courses\n\nBody content.",
67
- });
68
-
69
- const element = await CoursesPage({
70
- params: Promise.resolve({ locale: "en" }),
71
- // No child pages: this snapshot pins the hub's own render (#10121).
72
- getMdxSlugs: async () => [],
73
- getMdxSource,
74
- });
75
- const { container } = render(element);
76
- expect(container.innerHTML).toMatchInlineSnapshot(`
77
- "<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@type":"CollectionPage","inLanguage":"en","name":"Courses","description":"Structured learning paths for teams adopting AILK.","mainEntity":{"@type":"ItemList","itemListElement":[{"@type":"Course"}]}}</script><main id="main"><div class="mx-auto w-full max-w-container-xl px-4 md:px-6 lg:px-8 py-section"><div data-testid="markdown-view-toggle" class="ailk-markdown-view-toggle"><div class="flex justify-end mb-3"><div role="radiogroup" aria-label="Page view" data-testid="markdown-view-toggle" class="inline-flex items-center gap-0.5 rounded-lg p-1 bg-(--color-surface-secondary)"><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&amp;>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) bg-(--color-bg) text-(--color-fg) shadow-sm" type="button" role="radio" aria-checked="true" aria-label="Rendered" tabindex="0" data-testid="markdown-view-toggle-rendered">Rendered</button><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&amp;>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) text-(--color-text-muted) hover:text-(--color-fg)" type="button" role="radio" aria-checked="false" aria-label="Markdown" tabindex="-1" data-testid="markdown-view-toggle-markdown">Markdown</button></div></div><div role="status" aria-live="polite" aria-atomic="true" class="sr-only" data-testid="markdown-view-toggle-status">Showing Rendered view</div><div data-testid="markdown-view-rendered"><article data-testid="mdx-body"><div class="ailk-prose max-w-none text-(--color-text-muted) text-body-sm leading-relaxed [&amp;>*:first-child]:mt-0 [&amp;_h2]:mt-block-loose [&amp;_h2]:scroll-mt-24 [&amp;_h2]:text-heading-3 [&amp;_h2]:font-display [&amp;_h2]:text-(--color-fg) [&amp;_h3]:mt-block-loose [&amp;_h3]:scroll-mt-24 [&amp;_h3]:text-heading-4 [&amp;_h3]:font-display [&amp;_h3]:text-(--color-fg) [&amp;_h4]:mt-block-tight [&amp;_h4]:scroll-mt-24 [&amp;_h4]:text-heading-4 [&amp;_h4]:font-display [&amp;_h4]:text-(--color-fg) [&amp;_h5]:mt-block-tight [&amp;_h5]:scroll-mt-24 [&amp;_h5]:text-heading-4 [&amp;_h5]:font-display [&amp;_h5]:text-(--color-fg) [&amp;_h6]:mt-block-tight [&amp;_h6]:scroll-mt-24 [&amp;_h6]:text-heading-4 [&amp;_h6]:font-display [&amp;_h6]:text-(--color-fg) [&amp;_p]:mt-paragraph [&amp;_strong]:font-semibold [&amp;_strong]:text-(--color-fg) [&amp;_em]:italic [&amp;_ul]:mt-paragraph [&amp;_ul]:list-disc [&amp;_ul]:ps-6 [&amp;_ol]:mt-paragraph [&amp;_ol]:list-decimal [&amp;_ol]:ps-6 [&amp;_li]:mt-1 [&amp;_li]:ps-1 [&amp;_li]:marker:text-(--color-text-muted) [&amp;_li>ul]:mt-1 [&amp;_li>ol]:mt-1 [&amp;_blockquote]:mt-paragraph [&amp;_blockquote]:border-s-4 [&amp;_blockquote]:border-(--color-border-strong) [&amp;_blockquote]:ps-4 [&amp;_blockquote]:italic [&amp;_blockquote]:text-(--color-text-muted) [&amp;_hr]:my-block-loose [&amp;_hr]:border-(--color-border) [&amp;_a]:text-(--color-accent) [&amp;_a]:underline [&amp;_a]:underline-offset-4 [&amp;_:not(pre)>code]:rounded [&amp;_:not(pre)>code]:bg-(--color-surface-secondary) [&amp;_:not(pre)>code]:px-1.5 [&amp;_:not(pre)>code]:py-0.5 [&amp;_:not(pre)>code]:text-code [&amp;_:not(pre)>code]:font-mono [&amp;_:not(pre)>code]:text-(--color-fg) [&amp;_pre]:mt-paragraph [&amp;_pre]:overflow-auto [&amp;_pre]:rounded-md [&amp;_pre]:border-hairline [&amp;_pre]:border-(--color-border) [&amp;_pre]:bg-(--color-bg) [&amp;_pre]:p-4 [&amp;_pre]:font-mono [&amp;_pre]:text-body-sm [&amp;_img]:mt-paragraph [&amp;_img]:h-auto [&amp;_img]:max-w-full [&amp;_img]:rounded-lg [&amp;_table]:mt-paragraph [&amp;_table]:w-full [&amp;_table]:border-collapse [&amp;_table]:text-body-sm [&amp;_th]:border-b [&amp;_th]:border-(--color-border) [&amp;_th]:bg-(--color-surface-secondary) [&amp;_th]:px-3 [&amp;_th]:py-2 [&amp;_th]:text-start [&amp;_th]:font-semibold [&amp;_th]:text-(--color-fg) [&amp;_td]:border-b [&amp;_td]:border-(--color-border) [&amp;_td]:px-3 [&amp;_td]:py-2 [&amp;_kbd]:rounded [&amp;_kbd]:border-hairline [&amp;_kbd]:border-(--color-border) [&amp;_kbd]:bg-(--color-surface-secondary) [&amp;_kbd]:px-1.5 [&amp;_kbd]:py-0.5 [&amp;_kbd]:text-caption [&amp;_kbd]:font-mono" data-testid="mdx-content"><div data-testid="mdx-rendered">## Courses
78
-
79
- Body content.</div></div></article></div></div></div></main>"
80
- `);
81
- });
82
- });
83
-
84
- describe("courses/[slug] — snapshot regression", () => {
85
- beforeEach(() => {
86
- mockNotFound.mockClear();
87
- });
88
-
89
- it("populated state renders deterministic HTML", async () => {
90
- const getMdxSource = jest.fn().mockResolvedValue({
91
- frontmatter: {
92
- type: "Course" as const,
93
- slug: "aeo-fundamentals",
94
- title: "AEO Fundamentals",
95
- description: "A practical course covering Layer 1 AEO rules.",
96
- },
97
- body: "## AEO Fundamentals\n\nBody content.",
98
- });
99
-
100
- const element = await CourseSlugPage({
101
- params: Promise.resolve({ locale: "en", slug: "aeo-fundamentals" }),
102
- getMdxSource,
103
- });
104
- const { container } = render(element);
105
- expect(container.innerHTML).toMatchInlineSnapshot(`
106
- "<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@graph":[{"@context":"https://schema.org","@type":"WebPage","inLanguage":"en","name":"AEO Fundamentals","description":"A practical course covering Layer 1 AEO rules.","mainEntity":{"@context":"https://schema.org","@type":"Course","name":"AEO Fundamentals","description":"A practical course covering Layer 1 AEO rules."}},{"@context":"https://schema.org","@type":"BreadcrumbList","inLanguage":"en","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http://localhost:3000/en/"},{"@type":"ListItem","position":2,"name":"Courses","item":"http://localhost:3000/en/courses"},{"@type":"ListItem","position":3,"name":"AEO Fundamentals","item":"http://localhost:3000/en/courses/aeo-fundamentals"}]}]}</script><main id="main"><div class="mx-auto w-full max-w-container-xl px-4 md:px-6 lg:px-8 py-section"><div data-testid="markdown-view-toggle" class="ailk-markdown-view-toggle"><div class="flex justify-end mb-3"><div role="radiogroup" aria-label="Page view" data-testid="markdown-view-toggle" class="inline-flex items-center gap-0.5 rounded-lg p-1 bg-(--color-surface-secondary)"><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&amp;>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) bg-(--color-bg) text-(--color-fg) shadow-sm" type="button" role="radio" aria-checked="true" aria-label="Rendered" tabindex="0" data-testid="markdown-view-toggle-rendered">Rendered</button><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&amp;>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) text-(--color-text-muted) hover:text-(--color-fg)" type="button" role="radio" aria-checked="false" aria-label="Markdown" tabindex="-1" data-testid="markdown-view-toggle-markdown">Markdown</button></div></div><div role="status" aria-live="polite" aria-atomic="true" class="sr-only" data-testid="markdown-view-toggle-status">Showing Rendered view</div><div data-testid="markdown-view-rendered"><article data-testid="mdx-body"><div class="ailk-prose max-w-none text-(--color-text-muted) text-body-sm leading-relaxed [&amp;>*:first-child]:mt-0 [&amp;_h2]:mt-block-loose [&amp;_h2]:scroll-mt-24 [&amp;_h2]:text-heading-3 [&amp;_h2]:font-display [&amp;_h2]:text-(--color-fg) [&amp;_h3]:mt-block-loose [&amp;_h3]:scroll-mt-24 [&amp;_h3]:text-heading-4 [&amp;_h3]:font-display [&amp;_h3]:text-(--color-fg) [&amp;_h4]:mt-block-tight [&amp;_h4]:scroll-mt-24 [&amp;_h4]:text-heading-4 [&amp;_h4]:font-display [&amp;_h4]:text-(--color-fg) [&amp;_h5]:mt-block-tight [&amp;_h5]:scroll-mt-24 [&amp;_h5]:text-heading-4 [&amp;_h5]:font-display [&amp;_h5]:text-(--color-fg) [&amp;_h6]:mt-block-tight [&amp;_h6]:scroll-mt-24 [&amp;_h6]:text-heading-4 [&amp;_h6]:font-display [&amp;_h6]:text-(--color-fg) [&amp;_p]:mt-paragraph [&amp;_strong]:font-semibold [&amp;_strong]:text-(--color-fg) [&amp;_em]:italic [&amp;_ul]:mt-paragraph [&amp;_ul]:list-disc [&amp;_ul]:ps-6 [&amp;_ol]:mt-paragraph [&amp;_ol]:list-decimal [&amp;_ol]:ps-6 [&amp;_li]:mt-1 [&amp;_li]:ps-1 [&amp;_li]:marker:text-(--color-text-muted) [&amp;_li>ul]:mt-1 [&amp;_li>ol]:mt-1 [&amp;_blockquote]:mt-paragraph [&amp;_blockquote]:border-s-4 [&amp;_blockquote]:border-(--color-border-strong) [&amp;_blockquote]:ps-4 [&amp;_blockquote]:italic [&amp;_blockquote]:text-(--color-text-muted) [&amp;_hr]:my-block-loose [&amp;_hr]:border-(--color-border) [&amp;_a]:text-(--color-accent) [&amp;_a]:underline [&amp;_a]:underline-offset-4 [&amp;_:not(pre)>code]:rounded [&amp;_:not(pre)>code]:bg-(--color-surface-secondary) [&amp;_:not(pre)>code]:px-1.5 [&amp;_:not(pre)>code]:py-0.5 [&amp;_:not(pre)>code]:text-code [&amp;_:not(pre)>code]:font-mono [&amp;_:not(pre)>code]:text-(--color-fg) [&amp;_pre]:mt-paragraph [&amp;_pre]:overflow-auto [&amp;_pre]:rounded-md [&amp;_pre]:border-hairline [&amp;_pre]:border-(--color-border) [&amp;_pre]:bg-(--color-bg) [&amp;_pre]:p-4 [&amp;_pre]:font-mono [&amp;_pre]:text-body-sm [&amp;_img]:mt-paragraph [&amp;_img]:h-auto [&amp;_img]:max-w-full [&amp;_img]:rounded-lg [&amp;_table]:mt-paragraph [&amp;_table]:w-full [&amp;_table]:border-collapse [&amp;_table]:text-body-sm [&amp;_th]:border-b [&amp;_th]:border-(--color-border) [&amp;_th]:bg-(--color-surface-secondary) [&amp;_th]:px-3 [&amp;_th]:py-2 [&amp;_th]:text-start [&amp;_th]:font-semibold [&amp;_th]:text-(--color-fg) [&amp;_td]:border-b [&amp;_td]:border-(--color-border) [&amp;_td]:px-3 [&amp;_td]:py-2 [&amp;_kbd]:rounded [&amp;_kbd]:border-hairline [&amp;_kbd]:border-(--color-border) [&amp;_kbd]:bg-(--color-surface-secondary) [&amp;_kbd]:px-1.5 [&amp;_kbd]:py-0.5 [&amp;_kbd]:text-caption [&amp;_kbd]:font-mono" data-testid="mdx-content"><div data-testid="mdx-rendered">## AEO Fundamentals
107
-
108
- Body content.</div></div></article></div></div></div></main>"
109
- `);
110
- });
111
-
112
- it("unknown slug triggers notFound()", async () => {
113
- const getMdxSource = jest.fn().mockResolvedValue(null);
114
-
115
- await expect(
116
- CourseSlugPage({
117
- params: Promise.resolve({ locale: "en", slug: "unknown-slug" }),
118
- getMdxSource,
119
- }),
120
- ).rejects.toThrow("NEXT_NOT_FOUND");
121
- expect(mockNotFound).toHaveBeenCalled();
122
- });
123
- });
@@ -1,49 +0,0 @@
1
- // Courses list page. Reads CoursesList MDX via the content adapter and emits
2
- // a JSON-LD CollectionPage via the dispatcher.
3
- // It lists every Course page through one generated card section (#10121,
4
- // apps/web/lib/hub-children.tsx — the /alternatives and /templates shape).
5
- import type {
6
- getMdxSlugs as defaultGetMdxSlugs,
7
- getMdxSource as defaultGetMdxSource,
8
- getPageSections as defaultGetPageSections,
9
- } from "@working-theory/page-renderer";
10
- import { renderPage, renderPageMetadata } from "@working-theory/page-renderer";
11
- import type { Metadata } from "next";
12
- import type { ReactElement } from "react";
13
-
14
- import { type HubConfig, hubPageInput } from "../../../lib/hub-children";
15
-
16
- interface Props {
17
- params: Promise<{ locale: string }>;
18
- getMdxSource?: typeof defaultGetMdxSource;
19
- getPageSections?: typeof defaultGetPageSections;
20
- getMdxSlugs?: typeof defaultGetMdxSlugs;
21
- }
22
-
23
- const HUB: HubConfig = {
24
- listType: "CoursesList",
25
- slug: "courses",
26
- childType: "Course",
27
- linkLabel: "View the course",
28
- sectionId: "course-cards",
29
- body: "mdx-body",
30
- };
31
-
32
- export async function generateMetadata({
33
- params,
34
- }: Pick<Props, "params">): Promise<Metadata> {
35
- const { locale } = await params;
36
- return renderPageMetadata({ type: "CoursesList", slug: "courses", locale });
37
- }
38
-
39
- export default async function Page({
40
- params,
41
- ...loaders
42
- }: Props): Promise<ReactElement> {
43
- const { locale } = await params;
44
- return renderPage({
45
- type: "CoursesList",
46
- slug: "courses",
47
- ...(await hubPageInput(HUB, locale, loaders)),
48
- });
49
- }
@@ -1,57 +0,0 @@
1
- // Event detail page. Reads the Event MDX for the given slug, renders via
2
- // renderPage, and emits a JSON-LD <script>. Unknown slugs 404 through renderPage.
3
- // An Event under a program (`parent`) lives at /<program>/<event> (#10552), so
4
- // this URL answers a 308 there.
5
- import type { getMdxSource as defaultGetMdxSource } from "@working-theory/page-renderer";
6
- import {
7
- getMdxSource as loadMdxSource,
8
- renderPage,
9
- renderPageMetadata,
10
- } from "@working-theory/page-renderer";
11
- import type { Metadata } from "next";
12
- import { permanentRedirect } from "next/navigation";
13
- import type { ReactElement } from "react";
14
-
15
- interface Props {
16
- params: Promise<{ locale: string; slug: string }>;
17
- getMdxSource?: typeof defaultGetMdxSource;
18
- }
19
-
20
- export async function generateMetadata({
21
- params,
22
- }: Pick<Props, "params">): Promise<Metadata> {
23
- const { locale, slug } = await params;
24
- return renderPageMetadata({ type: "Event", slug, locale });
25
- }
26
-
27
- export default async function Page({
28
- params,
29
- getMdxSource,
30
- }: Props): Promise<ReactElement> {
31
- const { locale, slug } = await params;
32
- // A page that composes `sections[]` renders them (JSON-LD is built from
33
- // the same sections); a prose page renders its MDX body — the rule
34
- // /vs/[slug] applies (#10122).
35
- const load = getMdxSource ?? loadMdxSource;
36
- const source = await load("Event", slug, locale);
37
- const parent = source?.frontmatter.parent;
38
- // Only to a program the program route serves (a LandingPage at /<parent>),
39
- // so a mistyped `parent` never turns this URL into a dead redirect.
40
- if (parent !== undefined && (await load("LandingPage", parent, locale)) !== null) {
41
- const defaultLocale = process.env.NEXT_PUBLIC_DEFAULT_LOCALE ?? "en";
42
- const prefix = locale === defaultLocale ? "" : `/${locale}`;
43
- permanentRedirect(`${prefix}/${parent}/${slug}`);
44
- }
45
- const composed =
46
- source !== null &&
47
- Array.isArray((source.frontmatter as { sections?: unknown[] }).sections) &&
48
- ((source.frontmatter as { sections?: unknown[] }).sections?.length ?? 0) >
49
- 0;
50
- return renderPage({
51
- type: "Event",
52
- slug,
53
- locale,
54
- ...(composed ? {} : { bodyMode: "mdx-body" as const }),
55
- ...(getMdxSource !== undefined && { getMdxSource }),
56
- });
57
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * Hub child cards (#10121) for /events. The shared cases live in
3
- * `lib/__tests__/hub-children.fixtures.ts`; this file sits beside the route so
4
- * a scaffold without /events drops it with the route (#10157).
5
- */
6
- const mockRenderPage = jest.fn(async (..._args: unknown[]) => "<rendered/>");
7
-
8
- jest.mock("@working-theory/page-renderer", () => ({
9
- __esModule: true,
10
- renderPage: (...args: unknown[]) => mockRenderPage(...args),
11
- renderPageMetadata: jest.fn(),
12
- // Never reached — every call in this suite passes its loaders via DI.
13
- getMdxSlugs: jest.fn(),
14
- getMdxSource: jest.fn(),
15
- getPageSections: jest.fn(),
16
- }));
17
-
18
- jest.mock("@working-theory/ui/sections", () => ({
19
- __esModule: true,
20
- SectionRenderer: () => null,
21
- }));
22
-
23
- import EventsPage from "../page";
24
- import {
25
- describeHub,
26
- type HubPage,
27
- } from "../../../../lib/__tests__/hub-children.fixtures";
28
-
29
- describeHub(
30
- ["events", EventsPage as HubPage, "EventsList", "Event", "mdx-body"],
31
- mockRenderPage,
32
- );