create-ailk 0.39.0 → 0.40.1

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 (203) hide show
  1. package/component-catalog.json +1 -1
  2. package/component-catalog.md +1 -1
  3. package/dist/add-route.js +15 -0
  4. package/dist/body-heading.d.ts +2 -1
  5. package/dist/body-heading.js +31 -3
  6. package/dist/module-architecture.js +0 -3
  7. package/dist/remove-module.js +13 -4
  8. package/dist/routes.d.ts +7 -0
  9. package/dist/routes.js +1 -1
  10. package/dist/site-roster.js +7 -1
  11. package/dist/surfaces.d.ts +2 -0
  12. package/dist/surfaces.js +59 -172
  13. package/package.json +3 -3
  14. package/templates/apps/web/CLAUDE.md +19 -2
  15. package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +3 -2
  16. package/templates/apps/web/__tests__/__mocks__/next-intl.ts +3 -2
  17. package/templates/apps/web/app/[locale]/layout.tsx +42 -25
  18. package/templates/apps/web/app/api/revalidate/__tests__/route.test.ts +56 -1
  19. package/templates/apps/web/app/api/revalidate/route.ts +45 -4
  20. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +53 -0
  21. package/templates/apps/web/app/llms.txt/route.ts +5 -2
  22. package/templates/apps/web/i18n/request.ts +5 -1
  23. package/templates/apps/web/jest.config.cjs +6 -0
  24. package/templates/apps/web/lib/__tests__/deck-page.test.ts +9 -0
  25. package/templates/apps/web/lib/__tests__/hub-site-config.test.ts +239 -0
  26. package/templates/apps/web/lib/__tests__/in-page-magnet-self-request.test.ts +1 -1
  27. package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +2 -2
  28. package/templates/apps/web/lib/__tests__/pricing-page.test.ts +1 -1
  29. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +58 -0
  30. package/templates/apps/web/lib/__tests__/served-pages.test.ts +163 -20
  31. package/templates/apps/web/lib/__tests__/site-brand.test.ts +77 -0
  32. package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +64 -0
  33. package/templates/apps/web/lib/__tests__/site-identity-feature-list.test.ts +115 -3
  34. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
  35. package/templates/apps/web/lib/hub-site-config.ts +151 -0
  36. package/templates/apps/web/lib/in-page-magnet.ts +2 -2
  37. package/templates/apps/web/lib/pricing-page.ts +3 -3
  38. package/templates/apps/web/lib/profile-back-link.ts +49 -12
  39. package/templates/apps/web/lib/served-pages.ts +144 -39
  40. package/templates/apps/web/lib/site-brand.tsx +66 -0
  41. package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +25 -5
  42. package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +21 -5
  43. package/templates/apps/web/lib/site-header.ts +1 -1
  44. package/templates/apps/web/lib/site-identity.ts +38 -2
  45. package/templates/apps/web/messages/en.json +3 -119
  46. package/templates/apps/web/next.config.mjs +7 -0
  47. package/templates/apps/web/package.json +1 -0
  48. package/templates/apps/web/site-pages.config.tsx +85 -0
  49. package/templates/tools/body-heading.ts +30 -3
  50. package/versions.json +50 -49
  51. package/templates/apps/web/app/[locale]/(authed)/leads/__tests__/page.test.tsx +0 -205
  52. package/templates/apps/web/app/[locale]/(authed)/leads/components/LeadsTable.tsx +0 -137
  53. package/templates/apps/web/app/[locale]/(authed)/leads/page.tsx +0 -122
  54. package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ForbiddenState.tsx +0 -24
  55. package/templates/apps/web/app/[locale]/(authed)/waitlist/format.ts +0 -111
  56. package/templates/apps/web/app/[locale]/[slug]/[detail]/__tests__/page.test.tsx +0 -402
  57. package/templates/apps/web/app/[locale]/[slug]/[detail]/page.tsx +0 -143
  58. package/templates/apps/web/app/[locale]/[slug]/__tests__/page.test.tsx +0 -148
  59. package/templates/apps/web/app/[locale]/[slug]/page.tsx +0 -109
  60. package/templates/apps/web/app/[locale]/about/[slug]/page.tsx +0 -46
  61. package/templates/apps/web/app/[locale]/about/__tests__/about-routes.test.tsx +0 -353
  62. package/templates/apps/web/app/[locale]/about/page.tsx +0 -122
  63. package/templates/apps/web/app/[locale]/alternatives/__tests__/page.test.tsx +0 -161
  64. package/templates/apps/web/app/[locale]/alternatives/page.tsx +0 -112
  65. package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +0 -244
  66. package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +0 -325
  67. package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +0 -120
  68. package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +0 -73
  69. package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +0 -497
  70. package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +0 -172
  71. package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +0 -153
  72. package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +0 -141
  73. package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +0 -546
  74. package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +0 -189
  75. package/templates/apps/web/app/[locale]/careers/page.tsx +0 -165
  76. package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +0 -49
  77. package/templates/apps/web/app/[locale]/case-studies/__tests__/hub-children.test.tsx +0 -65
  78. package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +0 -125
  79. package/templates/apps/web/app/[locale]/case-studies/page.tsx +0 -49
  80. package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +0 -85
  81. package/templates/apps/web/app/[locale]/clients/page.tsx +0 -47
  82. package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +0 -249
  83. package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +0 -400
  84. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-magnet.test.ts +0 -138
  85. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-text.test.ts +0 -49
  86. package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +0 -494
  87. package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +0 -1122
  88. package/templates/apps/web/app/[locale]/contact/__tests__/intake-analytics.test.ts +0 -51
  89. package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +0 -319
  90. package/templates/apps/web/app/[locale]/contact/contact-form-magnet.ts +0 -77
  91. package/templates/apps/web/app/[locale]/contact/contact-form-text.ts +0 -52
  92. package/templates/apps/web/app/[locale]/contact/contact.actions.ts +0 -403
  93. package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +0 -49
  94. package/templates/apps/web/app/[locale]/contact/intake-script.ts +0 -92
  95. package/templates/apps/web/app/[locale]/contact/page.tsx +0 -267
  96. package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +0 -50
  97. package/templates/apps/web/app/[locale]/courses/__tests__/hub-children.test.tsx +0 -32
  98. package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +0 -123
  99. package/templates/apps/web/app/[locale]/courses/page.tsx +0 -49
  100. package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +0 -57
  101. package/templates/apps/web/app/[locale]/events/__tests__/hub-children.test.tsx +0 -32
  102. package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +0 -164
  103. package/templates/apps/web/app/[locale]/events/__tests__/program-event.test.tsx +0 -120
  104. package/templates/apps/web/app/[locale]/events/page.tsx +0 -60
  105. package/templates/apps/web/app/[locale]/faq/page.tsx +0 -54
  106. package/templates/apps/web/app/[locale]/features/[slug]/page.tsx +0 -54
  107. package/templates/apps/web/app/[locale]/features/__tests__/hub-children.test.tsx +0 -32
  108. package/templates/apps/web/app/[locale]/features/page.tsx +0 -50
  109. package/templates/apps/web/app/[locale]/for/[slug]/page.tsx +0 -54
  110. package/templates/apps/web/app/[locale]/for/__tests__/hub-children.test.tsx +0 -32
  111. package/templates/apps/web/app/[locale]/for/__tests__/page-renderer-migration.test.tsx +0 -90
  112. package/templates/apps/web/app/[locale]/for/page.tsx +0 -51
  113. package/templates/apps/web/app/[locale]/glossary/page.tsx +0 -53
  114. package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +0 -50
  115. package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +0 -78
  116. package/templates/apps/web/app/[locale]/how-to/page.tsx +0 -50
  117. package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +0 -54
  118. package/templates/apps/web/app/[locale]/integrations/__tests__/hub-children.test.tsx +0 -38
  119. package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +0 -141
  120. package/templates/apps/web/app/[locale]/integrations/page.tsx +0 -49
  121. package/templates/apps/web/app/[locale]/launch-service/page.tsx +0 -44
  122. package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +0 -236
  123. package/templates/apps/web/app/[locale]/newsletter/page.tsx +0 -179
  124. package/templates/apps/web/app/[locale]/page.tsx +0 -147
  125. package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +0 -45
  126. package/templates/apps/web/app/[locale]/partners/__tests__/hub-children.test.tsx +0 -32
  127. package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +0 -125
  128. package/templates/apps/web/app/[locale]/partners/page.tsx +0 -49
  129. package/templates/apps/web/app/[locale]/portfolio/[slug]/page.tsx +0 -46
  130. package/templates/apps/web/app/[locale]/portfolio/__tests__/hub-children.test.tsx +0 -38
  131. package/templates/apps/web/app/[locale]/portfolio/page.tsx +0 -50
  132. package/templates/apps/web/app/[locale]/pricing/[slug]/__tests__/page.test.tsx +0 -324
  133. package/templates/apps/web/app/[locale]/pricing/[slug]/page.tsx +0 -87
  134. package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +0 -7
  135. package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +0 -605
  136. package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +0 -219
  137. package/templates/apps/web/app/[locale]/pricing/__tests__/pricing-pages.test.tsx +0 -215
  138. package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +0 -282
  139. package/templates/apps/web/app/[locale]/pricing/page.tsx +0 -120
  140. package/templates/apps/web/app/[locale]/privacy/page.tsx +0 -40
  141. package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +0 -50
  142. package/templates/apps/web/app/[locale]/products/__tests__/hub-children.test.tsx +0 -32
  143. package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +0 -141
  144. package/templates/apps/web/app/[locale]/products/page.tsx +0 -49
  145. package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +0 -37
  146. package/templates/apps/web/app/[locale]/projects/__tests__/hub-children.test.tsx +0 -32
  147. package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +0 -157
  148. package/templates/apps/web/app/[locale]/projects/page.tsx +0 -49
  149. package/templates/apps/web/app/[locale]/purchase-policy/page.tsx +0 -49
  150. package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +0 -54
  151. package/templates/apps/web/app/[locale]/resources/__tests__/hub-children.test.tsx +0 -38
  152. package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +0 -151
  153. package/templates/apps/web/app/[locale]/resources/page.tsx +0 -49
  154. package/templates/apps/web/app/[locale]/services/[slug]/[child]/page.tsx +0 -68
  155. package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +0 -88
  156. package/templates/apps/web/app/[locale]/services/__tests__/hub-children.test.tsx +0 -158
  157. package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +0 -187
  158. package/templates/apps/web/app/[locale]/services/__tests__/service-detail-sections.test.tsx +0 -224
  159. package/templates/apps/web/app/[locale]/services/__tests__/service-families.test.tsx +0 -368
  160. package/templates/apps/web/app/[locale]/services/page.tsx +0 -71
  161. package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +0 -49
  162. package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +0 -81
  163. package/templates/apps/web/app/[locale]/software/page.tsx +0 -49
  164. package/templates/apps/web/app/[locale]/team/[slug]/page.tsx +0 -45
  165. package/templates/apps/web/app/[locale]/team/__tests__/hub-children.test.tsx +0 -32
  166. package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +0 -161
  167. package/templates/apps/web/app/[locale]/team/page.tsx +0 -50
  168. package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +0 -54
  169. package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +0 -82
  170. package/templates/apps/web/app/[locale]/tech-articles/page.tsx +0 -49
  171. package/templates/apps/web/app/[locale]/templates/[slug]/__tests__/page.test.tsx +0 -203
  172. package/templates/apps/web/app/[locale]/templates/[slug]/page.tsx +0 -81
  173. package/templates/apps/web/app/[locale]/templates/__tests__/page.test.tsx +0 -237
  174. package/templates/apps/web/app/[locale]/templates/page.tsx +0 -114
  175. package/templates/apps/web/app/[locale]/terms/page.tsx +0 -40
  176. package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +0 -85
  177. package/templates/apps/web/app/[locale]/testimonials/page.tsx +0 -51
  178. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +0 -136
  179. package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +0 -39
  180. package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +0 -226
  181. package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +0 -217
  182. package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +0 -106
  183. package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +0 -94
  184. package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe.actions.ts +0 -55
  185. package/templates/apps/web/app/[locale]/vs/[slug]/__tests__/page.test.tsx +0 -100
  186. package/templates/apps/web/app/[locale]/vs/[slug]/page.tsx +0 -60
  187. package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +0 -54
  188. package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +0 -82
  189. package/templates/apps/web/app/[locale]/whitepapers/page.tsx +0 -49
  190. package/templates/apps/web/app/[locale]/working-agreement/__tests__/page.test.tsx +0 -63
  191. package/templates/apps/web/app/[locale]/working-agreement/page.tsx +0 -41
  192. package/templates/apps/web/lib/__tests__/hub-children.fixtures.ts +0 -279
  193. package/templates/apps/web/lib/__tests__/route-family.test.ts +0 -57
  194. package/templates/apps/web/lib/__tests__/service-listing.test.ts +0 -111
  195. package/templates/apps/web/lib/__tests__/template-listing.test.ts +0 -158
  196. package/templates/apps/web/lib/hub-children.tsx +0 -351
  197. package/templates/apps/web/lib/meet-placeholder.ts +0 -5
  198. package/templates/apps/web/lib/posting-title.ts +0 -39
  199. package/templates/apps/web/lib/route-family.ts +0 -69
  200. package/templates/apps/web/lib/service-listing.ts +0 -89
  201. package/templates/apps/web/lib/template-listing.ts +0 -169
  202. package/templates/apps/web/src/lib/__tests__/lead-write.test.ts +0 -187
  203. package/templates/apps/web/src/lib/lead-write.ts +0 -90
@@ -1,109 +0,0 @@
1
- // The one generic content route (#5469 D2). Serves the Free marketing-site
2
- // template's /blog teaser — and any other
3
- // `content/<locale>/LandingPage/<slug>.mdx` a site adds — through exactly the
4
- // render path the static routes use (`renderPage`, sections mode, JSON-LD
5
- // from frontmatter — a page's `schema:` override rides the escape hatch,
6
- // though the structured-data gate only accepts a `WebPage` primary block
7
- // for a LandingPage, so the Free template's pages set none).
8
- //
9
- // Precedence, not gating: Next.js resolves a static segment before a dynamic
10
- // one, so this route never shadows a scaffolded route directory. That is what
11
- // lets /blog degrade — keyless there is no `blog/` directory and the teaser
12
- // renders here; with the docs-blog module its `blog/[[...slug]]` directory
13
- // wins and the teaser file is inert (#5469 D3).
14
- //
15
- // Two content types, in a fixed order: `LandingPage` first (the coined
16
- // slug-keyed landing surface whose builder emits a `WebPage` envelope), then
17
- // `BlogList` — the one list type that cannot have a route directory of its
18
- // own, because the docs-blog module owns `blog/` (`blog/[[...slug]]`) and
19
- // Next.js refuses a `blog/page.tsx` beside an optional catch-all. So the
20
- // Free `/blog` teaser is a `BlogList` page (schema `Blog` + an empty
21
- // `ItemList` — the correct page type, not a LandingPage wearing a `schema:`
22
- // override the structured-data gate rejects) served here, and still yields
23
- // to the module's directory by the same precedence. Every other list type
24
- // has its own route directory (`/features` → ProductsList, `/for` →
25
- // UseCasesList) and never reaches this route.
26
- //
27
- // Unknown slug → `notFound()` (renderPage's own detail-route branch: no
28
- // `translationsNamespace` is passed, so a null source 404s rather than
29
- // rendering an empty-state placeholder).
30
- //
31
- // Deliberately NO `generateStaticParams`: the locale layout reads cookies()
32
- // and headers() (theme, session), so every route under it renders on
33
- // request. A static-params export would make Next try to prerender this
34
- // segment and fail any slug outside the build-time list with
35
- // DYNAMIC_SERVER_USAGE (a 500, not the 404 an unknown slug must get).
36
- import type { getMdxSource as defaultGetMdxSource } from "@working-theory/page-renderer";
37
- import {
38
- getMdxSource as loadMdxSource,
39
- renderPage,
40
- renderPageMetadata,
41
- } from "@working-theory/page-renderer";
42
- import type { Metadata } from "next";
43
- import type { ReactElement } from "react";
44
-
45
- import { honourNavOnly } from "../../../lib/hub-children";
46
-
47
- // The content type is written as a literal in both renderPage calls below
48
- // (not a shared constant): `lib/__tests__/structured-data.test.tsx` and
49
- // tools/lint-check-content-renders.ts read `renderPage({ type: "…" })` off
50
- // the source to know which content this route emits JSON-LD for.
51
-
52
- interface Props {
53
- params: Promise<{ locale: string; slug: string }>;
54
- /** Test-only DI override for getMdxSource. Production callers leave undefined. */
55
- getMdxSource?: typeof defaultGetMdxSource;
56
- }
57
-
58
- /**
59
- * Which of the two content types carries this slug. `LandingPage` wins when
60
- * it exists; `BlogList` is probed only when it does not, so a LandingPage
61
- * slug never pays a second adapter read. Neither → `LandingPage`, whose null
62
- * source is what makes renderPage 404.
63
- */
64
- async function resolveType(
65
- slug: string,
66
- locale: string,
67
- getMdxSource: typeof defaultGetMdxSource,
68
- ): Promise<"LandingPage" | "BlogList"> {
69
- if ((await getMdxSource("LandingPage", slug, locale)) !== null) return "LandingPage";
70
- if ((await getMdxSource("BlogList", slug, locale)) !== null) return "BlogList";
71
- return "LandingPage";
72
- }
73
-
74
- export async function generateMetadata({
75
- params,
76
- getMdxSource,
77
- }: Pick<Props, "params" | "getMdxSource">): Promise<Metadata> {
78
- const { locale, slug } = await params;
79
- const load = getMdxSource ?? loadMdxSource;
80
- const type = await resolveType(slug, locale, load);
81
- return renderPageMetadata({ type, slug, locale });
82
- }
83
-
84
- export default async function Page({
85
- params,
86
- getMdxSource,
87
- }: Props): Promise<ReactElement> {
88
- const { locale, slug } = await params;
89
- const load = getMdxSource ?? loadMdxSource;
90
- const type = await resolveType(slug, locale, load);
91
- if (type === "BlogList") {
92
- const source = await load("BlogList", slug, locale);
93
- honourNavOnly(source?.frontmatter, locale, []);
94
- return renderPage({
95
- type: "BlogList",
96
- slug,
97
- locale,
98
- populatedDescriptionTestId: `${slug}-description`,
99
- ...(getMdxSource !== undefined && { getMdxSource }),
100
- });
101
- }
102
- return renderPage({
103
- type: "LandingPage",
104
- slug,
105
- locale,
106
- populatedDescriptionTestId: `${slug}-description`,
107
- ...(getMdxSource !== undefined && { getMdxSource }),
108
- });
109
- }
@@ -1,46 +0,0 @@
1
- // A person's own page (#8650 D3). Reads the Person MDX for the given slug and
2
- // emits a JSON-LD <script>. Unknown slugs 404 through renderPage. Renders
3
- // `sections[]` when the frontmatter carries them (the /for composed
4
- // pattern), MDX prose otherwise.
5
- import {
6
- getMdxSource as defaultGetMdxSource,
7
- renderPage,
8
- renderPageMetadata,
9
- } from "@working-theory/page-renderer";
10
- import type { Metadata } from "next";
11
- import type { ReactElement } from "react";
12
-
13
- interface Props {
14
- params: Promise<{ locale: string; slug: string }>;
15
- getMdxSource?: typeof defaultGetMdxSource;
16
- }
17
-
18
- export async function generateMetadata({
19
- params,
20
- }: Pick<Props, "params">): Promise<Metadata> {
21
- const { locale, slug } = await params;
22
- return renderPageMetadata({ type: "Person", slug, locale });
23
- }
24
-
25
- export default async function Page({
26
- params,
27
- getMdxSource = defaultGetMdxSource,
28
- }: Props): Promise<ReactElement> {
29
- const { locale, slug } = await params;
30
- // Read once to pick the body mode. A null source still goes to renderPage,
31
- // which owns the unknown-slug branch (#7537).
32
- const source = await getMdxSource("Person", slug, locale);
33
-
34
- const composed =
35
- source !== null &&
36
- Array.isArray((source.frontmatter as { sections?: unknown[] }).sections) &&
37
- ((source.frontmatter as { sections?: unknown[] }).sections?.length ?? 0) > 0;
38
-
39
- return renderPage({
40
- type: "Person",
41
- slug,
42
- locale,
43
- ...(composed ? {} : { bodyMode: "mdx-body" as const }),
44
- getMdxSource: async () => source,
45
- });
46
- }
@@ -1,353 +0,0 @@
1
- /**
2
- * The about routes (#8650 spec, AC-1 through AC-4):
3
- *
4
- * - AC-1: `/about/<slug>` renders a `ProfilePage` whose `mainEntity` is a
5
- * `Person`, valid under the schema validator, with an About breadcrumb; an
6
- * unknown slug 404s through `renderPage`.
7
- * - AC-2: `/about` lists every `Person` page as a generated `team` section,
8
- * each member linking to its own `/about/<slug>` page, before a trailing
9
- * `cta` section.
10
- * - AC-3: the routes map, sitemap and `llms.txt` all advertise a `Person`
11
- * page at `/about/<slug>`, never a bare `/<slug>`.
12
- * - AC-4: with zero `Person` pages, `/about` renders byte-identical to
13
- * calling `renderPage` directly (C5 — a fresh scaffold is such a site).
14
- *
15
- * MDX sources are inline stubs (no fs reads) for AC-2/AC-4, and a real
16
- * `createMdxAdapter` over a temp content root for AC-1 (the spec's own
17
- * method) — both run unchanged inside a scaffold.
18
- */
19
- import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
20
- import { tmpdir } from "node:os";
21
- import { join } from "node:path";
22
-
23
- import { render } from "@testing-library/react";
24
- import { createMdxAdapter } from "@working-theory/content-adapters";
25
- import * as pageRenderer from "@working-theory/page-renderer";
26
- import { validatePageGraph } from "@working-theory/schema-validator";
27
- import React from "react";
28
-
29
- jest.mock("next/navigation", () => ({
30
- __esModule: true,
31
- notFound: jest.fn(() => {
32
- throw new Error("NEXT_NOT_FOUND");
33
- }),
34
- }));
35
-
36
- jest.mock("next-mdx-remote/rsc", () => ({
37
- __esModule: true,
38
- MDXRemote: ({ source }: { source: string }) =>
39
- React.createElement("div", { "data-testid": "mdx-rendered" }, source),
40
- }));
41
-
42
- import AboutPage from "../page";
43
- import AboutPersonPage from "../[slug]/page";
44
- import { createSitemapHandler } from "../../../sitemap.xml/route";
45
- import { createLlmsHandler } from "../../../llms.txt/route";
46
- import type { ContentAdapter } from "@working-theory/content-adapters";
47
-
48
- // #10704 — a fixture suite: its content is shaped for the mdx source, whatever the site serves from.
49
- process.env.CONTENT_ADAPTER = "mdx";
50
-
51
- type JsonLd = Record<string, unknown>;
52
-
53
- function jsonLdScripts(container: HTMLElement): JsonLd[] {
54
- return [
55
- ...container.querySelectorAll("script[type='application/ld+json']"),
56
- ].map((s) => JSON.parse(s.textContent ?? "") as JsonLd);
57
- }
58
-
59
- describe("about/[slug] — a person's own page (AC-1)", () => {
60
- let root: string;
61
-
62
- beforeAll(() => {
63
- root = mkdtempSync(join(tmpdir(), "ailk-8650-"));
64
- mkdirSync(join(root, "en", "Person"), { recursive: true });
65
- writeFileSync(
66
- join(root, "en", "Person", "sam-henry.mdx"),
67
- [
68
- "---",
69
- "type: Person",
70
- "slug: sam-henry",
71
- "title: Sam Henry",
72
- "description: Co-founder and partner.",
73
- "schema:",
74
- " jobTitle: Partner",
75
- "---",
76
- "",
77
- "Sam Henry, co-founder and partner.",
78
- "",
79
- ].join("\n"),
80
- );
81
- });
82
-
83
- afterAll(() => {
84
- rmSync(root, { recursive: true, force: true });
85
- });
86
-
87
- it("emits one ProfilePage graph whose Person carries @id #person, valid under the schema validator", async () => {
88
- const adapter = createMdxAdapter({ contentRoot: root, defaultLocale: "en" });
89
- const element = await AboutPersonPage({
90
- params: Promise.resolve({ locale: "en", slug: "sam-henry" }),
91
- getMdxSource: (type, slug, locale) =>
92
- adapter.getPageSource(type, slug, locale),
93
- });
94
- const { container } = render(element);
95
- const scripts = jsonLdScripts(container);
96
- expect(scripts).toHaveLength(1);
97
- const graph = scripts[0]!["@graph"] as JsonLd[];
98
- expect(validatePageGraph(graph as never, "Person")).toEqual(
99
- expect.objectContaining({ valid: true }),
100
- );
101
-
102
- const profile = graph.find((b) => b["@type"] === "ProfilePage")!;
103
- const person = profile["mainEntity"] as JsonLd;
104
- expect(person["@type"]).toBe("Person");
105
- expect(person["@id"]).toBe("#person");
106
- expect(person["name"]).toBe("Sam Henry");
107
- expect(person["jobTitle"]).toBe("Partner");
108
-
109
- const breadcrumb = graph.find((b) => b["@type"] === "BreadcrumbList")!;
110
- const items = breadcrumb["itemListElement"] as Array<{ item: string }>;
111
- expect(items[1]!.item).toMatch(/\/en\/about$/);
112
- });
113
-
114
- it("404s an unknown slug through renderPage, with no translations namespace", async () => {
115
- const renderPageSpy = jest.spyOn(pageRenderer, "renderPage");
116
- const adapter = createMdxAdapter({ contentRoot: root, defaultLocale: "en" });
117
- await expect(
118
- AboutPersonPage({
119
- params: Promise.resolve({ locale: "en", slug: "nobody" }),
120
- getMdxSource: (type, slug, locale) =>
121
- adapter.getPageSource(type, slug, locale),
122
- }),
123
- ).rejects.toThrow("NEXT_NOT_FOUND");
124
- expect(renderPageSpy).toHaveBeenCalledTimes(1);
125
- expect(
126
- renderPageSpy.mock.calls[0]![0].translationsNamespace,
127
- ).toBeUndefined();
128
- renderPageSpy.mockRestore();
129
- });
130
- });
131
-
132
- const ABOUT_WITH_CTA = {
133
- frontmatter: {
134
- type: "AboutPage",
135
- slug: "about",
136
- title: "About",
137
- description: "About us.",
138
- sections: [
139
- {
140
- id: "intro",
141
- type: "content-block",
142
- data: { headline: "About us", body: "We build things." },
143
- },
144
- {
145
- id: "closing",
146
- type: "cta",
147
- data: {
148
- headline: "Let's talk",
149
- primaryCta: { label: "Contact us", href: "/contact" },
150
- },
151
- },
152
- ],
153
- },
154
- body: "",
155
- };
156
-
157
- const SAM_SOURCE = {
158
- frontmatter: {
159
- type: "Person",
160
- slug: "sam-henry",
161
- title: "Sam Henry",
162
- description: "Co-founder and partner.",
163
- schema: { jobTitle: "Partner" },
164
- },
165
- body: "",
166
- };
167
-
168
- const WENDI_SOURCE = {
169
- frontmatter: {
170
- type: "Person",
171
- slug: "wendi-henry",
172
- title: "About Wendi",
173
- description: "Co-founder and partner.",
174
- schema: { name: "Wendi Henry" },
175
- },
176
- body: "",
177
- };
178
-
179
- describe("about — the generated people list (AC-2)", () => {
180
- it("lists every Person page as one team section, before the closing cta, linking to /about/<slug>", async () => {
181
- const getMdxSource = jest.fn(
182
- async (type: string, slug: string): Promise<unknown> => {
183
- if (type === "AboutPage") return ABOUT_WITH_CTA;
184
- if (type === "Person" && slug === "sam-henry") return SAM_SOURCE;
185
- if (type === "Person" && slug === "wendi-henry") return WENDI_SOURCE;
186
- return null;
187
- },
188
- );
189
- const getMdxSlugs = jest
190
- .fn()
191
- .mockResolvedValue(["wendi-henry", "sam-henry", "ghost-member"]);
192
-
193
- const element = await AboutPage({
194
- params: Promise.resolve({ locale: "en" }),
195
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- test double over a narrower DI surface than the real multi-type loader
196
- getMdxSource: getMdxSource as any,
197
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- test double
198
- getMdxSlugs: getMdxSlugs as any,
199
- });
200
- const { container } = render(element);
201
-
202
- const cards = container.querySelectorAll('[data-testid="team-member-card"]');
203
- // The null-source "ghost-member" slug is skipped — two cards, not three.
204
- expect(cards).toHaveLength(2);
205
-
206
- const links = container.querySelectorAll('[data-testid^="member-page-link-"]');
207
- const hrefs = [...links].map((l) => l.getAttribute("href"));
208
- expect(hrefs).toEqual(["/about/sam-henry", "/about/wendi-henry"]);
209
- for (const link of links) {
210
- expect(link.textContent).toBe("View profile");
211
- }
212
-
213
- // Wendi's card shows schema.name, not title; Sam's shows title (no
214
- // schema.name override) with his jobTitle as the role.
215
- expect(cards[0]!.textContent).toContain("Sam Henry");
216
- expect(cards[0]!.textContent).toContain("Partner");
217
- expect(cards[1]!.textContent).toContain("Wendi Henry");
218
- expect(cards[1]!.textContent).not.toContain("About Wendi");
219
- expect(cards[1]!.textContent).not.toContain("Partner");
220
-
221
- // The team section sits before the closing cta section in document order.
222
- const html = container.innerHTML;
223
- expect(html.indexOf("team-member-card")).toBeLessThan(
224
- html.indexOf("Let's talk"),
225
- );
226
- });
227
- });
228
-
229
- describe("about — unchanged with zero Person pages (AC-4, C5)", () => {
230
- it("renders byte-identical to a direct renderPage call", async () => {
231
- const aboutSource = {
232
- frontmatter: {
233
- type: "AboutPage",
234
- slug: "about",
235
- title: "About",
236
- description: "About us.",
237
- },
238
- body: "About us copy.",
239
- };
240
- const getMdxSource = jest.fn().mockResolvedValue(aboutSource);
241
- const getMdxSlugs = jest.fn().mockResolvedValue([]);
242
-
243
- const element = await AboutPage({
244
- params: Promise.resolve({ locale: "en" }),
245
- getMdxSource,
246
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- test double over a narrower DI surface than the real multi-type loader
247
- getMdxSlugs: getMdxSlugs as any,
248
- });
249
- const { container } = render(element);
250
-
251
- const direct = await pageRenderer.renderPage({
252
- type: "AboutPage",
253
- slug: "about",
254
- locale: "en",
255
- translationsNamespace: "about",
256
- getMdxSource,
257
- });
258
- const { container: directContainer } = render(direct);
259
-
260
- expect(container.innerHTML).toBe(directContainer.innerHTML);
261
- expect(
262
- container.querySelectorAll('[data-testid="team-member-card"]'),
263
- ).toHaveLength(0);
264
- });
265
- });
266
-
267
- describe("the sitemap and llms.txt advertise /about/<slug>, never a bare /<slug> (AC-3)", () => {
268
- // The route handlers construct a Web `Response`, which jsdom (this file's
269
- // test environment, needed by the React-rendering describes above) does
270
- // not implement. A minimal same-shape stand-in, scoped to this describe,
271
- // is enough for the one method these tests call: `.text()`.
272
- let originalResponse: unknown;
273
-
274
- beforeAll(() => {
275
- originalResponse = (globalThis as { Response?: unknown }).Response;
276
- class ResponseShim {
277
- private readonly _body: string;
278
- constructor(body: string, _init?: unknown) {
279
- this._body = body;
280
- }
281
- async text(): Promise<string> {
282
- return this._body;
283
- }
284
- }
285
- (globalThis as { Response: unknown }).Response = ResponseShim;
286
- });
287
-
288
- afterAll(() => {
289
- (globalThis as { Response?: unknown }).Response = originalResponse;
290
- });
291
-
292
- function makeStubAdapter(): ContentAdapter {
293
- // eslint-disable-next-line no-restricted-syntax -- jest.fn() stubs are not assignable to ContentAdapter's generic return types; partial stub is intentional, tracked in #1073
294
- return {
295
- listPages: jest.fn().mockImplementation(async (type: string) => {
296
- if (type === "Person") {
297
- return [
298
- {
299
- type: "Person",
300
- slug: "sam-henry",
301
- title: "Sam Henry",
302
- description: "Co-founder and partner.",
303
- },
304
- ];
305
- }
306
- return [];
307
- }),
308
- listDetail: jest.fn().mockResolvedValue([]),
309
- getPageBySlug: jest.fn().mockResolvedValue(null),
310
- getDetailBySlug: jest.fn().mockResolvedValue(null),
311
- searchPages: jest.fn().mockResolvedValue([]),
312
- extractStructuredData: jest.fn().mockResolvedValue(null),
313
- createPage: jest.fn(),
314
- updatePage: jest.fn(),
315
- deletePage: jest.fn(),
316
- getPageVersion: jest.fn(),
317
- } as unknown as ContentAdapter;
318
- }
319
-
320
- beforeEach(() => {
321
- process.env.NEXT_PUBLIC_ENABLED_LOCALES = "en";
322
- process.env.NEXT_PUBLIC_DEFAULT_LOCALE = "en";
323
- process.env.NEXT_PUBLIC_BASE_URL = "https://site.example";
324
- });
325
-
326
- afterEach(() => {
327
- delete process.env.NEXT_PUBLIC_ENABLED_LOCALES;
328
- delete process.env.NEXT_PUBLIC_DEFAULT_LOCALE;
329
- delete process.env.NEXT_PUBLIC_BASE_URL;
330
- jest.resetAllMocks();
331
- });
332
-
333
- it("sitemap.xml: one <loc> ending in /about/sam-henry, none ending in a bare /sam-henry", async () => {
334
- const stubAdapter = makeStubAdapter();
335
- const GET = createSitemapHandler({ getContentAdapter: () => stubAdapter, getDocsPages: () => [], discoverable: async () => true });
336
- const response = await GET();
337
- const text = await response.text();
338
- const locs = Array.from(text.matchAll(/<loc>([^<]*)<\/loc>/g)).map(
339
- (m) => m[1],
340
- );
341
- expect(locs).toContain("https://site.example/about/sam-henry");
342
- expect(locs).not.toContain("https://site.example/sam-henry");
343
- });
344
-
345
- it("llms.txt: names a URL ending in /about/sam-henry", async () => {
346
- const stubAdapter = makeStubAdapter();
347
- const GET = createLlmsHandler({ getContentAdapter: () => stubAdapter, getDocsPages: () => [], discoverable: async () => true });
348
- const response = await GET();
349
- const text = await response.text();
350
- expect(text).toContain("URL: https://site.example/about/sam-henry");
351
- expect(text).not.toContain("URL: https://site.example/sam-henry\n");
352
- });
353
- });
@@ -1,122 +0,0 @@
1
- // About page. Reads the AboutPage MDX frontmatter, renders sections via
2
- // SectionRenderer, and emits a JSON-LD <script>.
3
- //
4
- // #8650 D4 — `/about` additionally lists every `Person` page in the request's
5
- // locale as one generated `team` section (the `/alternatives` `withSpokes`
6
- // precedent, #6878 D9), each member linking to its own `/about/<slug>` page.
7
- // With zero `Person` pages the parsed sections are returned unchanged, so a
8
- // fresh scaffold (which seeds no `Person` file) renders exactly as before.
9
- import type {
10
- getMdxSlugs as defaultGetMdxSlugs,
11
- getMdxSource as defaultGetMdxSource,
12
- getPageSections as defaultGetPageSections} from "@working-theory/page-renderer";
13
- import {
14
- getMdxSlugs as loadMdxSlugs,
15
- getMdxSource as loadMdxSource,
16
- getPageSections as loadPageSections,
17
- renderPage,
18
- renderPageMetadata
19
- } from "@working-theory/page-renderer";
20
- import type { Metadata } from "next";
21
- import { getTranslations } from "next-intl/server";
22
- import type { ReactElement } from "react";
23
-
24
- interface Props {
25
- params: Promise<{ locale: string }>;
26
- getMdxSource?: typeof defaultGetMdxSource;
27
- getPageSections?: typeof defaultGetPageSections;
28
- getMdxSlugs?: typeof defaultGetMdxSlugs;
29
- }
30
-
31
- type Section = Awaited<ReturnType<typeof defaultGetPageSections>>[number];
32
-
33
- export async function generateMetadata({
34
- params,
35
- }: Pick<Props, "params">): Promise<Metadata> {
36
- const { locale } = await params;
37
- return renderPageMetadata({ type: "AboutPage", slug: "about", locale });
38
- }
39
-
40
- export default async function Page({
41
- params,
42
- getMdxSource,
43
- getPageSections,
44
- getMdxSlugs,
45
- }: Props): Promise<ReactElement> {
46
- const { locale } = await params;
47
- const loadSections = getPageSections ?? loadPageSections;
48
- const loadSlugs = getMdxSlugs ?? loadMdxSlugs;
49
- const loadSource = getMdxSource ?? loadMdxSource;
50
-
51
- /**
52
- * Append one generated `team` section listing every `Person` page (C3) —
53
- * the same "the visible list and the sections that feed JSON-LD always
54
- * agree" property `withSpokes` gives `/alternatives` (#6878 D9), since
55
- * `renderPage` builds both the body and the JSON-LD from these sections.
56
- * Returns `declared` unchanged whenever there is nothing to list, so a
57
- * site with no `Person` page renders byte-identical to today (AC-4, C5).
58
- */
59
- async function withPeople(frontmatter: unknown): Promise<Section[]> {
60
- const declared = await loadSections(frontmatter);
61
- const slugs = [...(await loadSlugs("Person", locale))].sort();
62
- if (slugs.length === 0) return declared;
63
-
64
- const t = await getTranslations({ locale, namespace: "about" });
65
- const label = t("viewProfile");
66
-
67
- const sources = await Promise.all(
68
- slugs.map((slug) => loadSource("Person", slug, locale)),
69
- );
70
-
71
- const members = sources.flatMap((source, i) => {
72
- if (source === null) return [];
73
- const slug = slugs[i]!;
74
- const fm = source.frontmatter as {
75
- title: string;
76
- description?: string;
77
- image?: string;
78
- schema?: { name?: string; jobTitle?: string };
79
- };
80
- const name =
81
- typeof fm.schema?.name === "string" ? fm.schema.name : fm.title;
82
- const role =
83
- typeof fm.schema?.jobTitle === "string" ? fm.schema.jobTitle : "";
84
- return [
85
- {
86
- name,
87
- role,
88
- ...(typeof fm.description === "string" && {
89
- bio: fm.description,
90
- }),
91
- ...(typeof fm.image === "string" && {
92
- avatar: { src: fm.image, alt: name },
93
- }),
94
- links: [{ type: "page" as const, url: `/about/${slug}`, label }],
95
- },
96
- ];
97
- });
98
-
99
- if (members.length === 0) return declared;
100
-
101
- const people: Section = {
102
- type: "team" as const,
103
- id: "people",
104
- data: { variant: "with-large-images" as const, members },
105
- };
106
-
107
- const last = declared.at(-1);
108
- if (last !== undefined && last.type === "cta") {
109
- return [...declared.slice(0, -1), people, last];
110
- }
111
- return [...declared, people];
112
- }
113
-
114
- return renderPage({
115
- type: "AboutPage",
116
- slug: "about",
117
- locale,
118
- translationsNamespace: "about",
119
- getPageSections: withPeople,
120
- ...(getMdxSource !== undefined && { getMdxSource }),
121
- });
122
- }