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,81 +0,0 @@
1
- // TemplatePage detail (#10051 D7) — one template at /templates/<slug>,
2
- // listed by the /templates hub. Reads the TemplatePage MDX for the given
3
- // slug and renders in sections mode: a generated hero (name, summary,
4
- // thumbnail, categories, Get it / Start free, View demo) and "What's
5
- // included", built from the frontmatter, then the page's own declared
6
- // sections. A page whose first declared section is a `hero` keeps its own
7
- // hero and drops the generated one. JSON-LD: a WebPage whose mainEntity is a
8
- // schema.org Product carrying an Offer. Unknown slugs 404 through
9
- // renderPage's detail branch.
10
- //
11
- // Gated off by default (surfaces.ts `templates` surface): no roster names
12
- // this route, so a fresh scaffold excludes it. `create-ailk add-route
13
- // templates` installs it.
14
- import type {
15
- getMdxSource as defaultGetMdxSource,
16
- getPageSections as defaultGetPageSections,
17
- } from "@working-theory/page-renderer";
18
- import {
19
- getPageSections as loadPageSections,
20
- renderPage,
21
- renderPageMetadata,
22
- } from "@working-theory/page-renderer";
23
- import type { Metadata } from "next";
24
- import { getTranslations } from "next-intl/server";
25
- import type { ReactElement } from "react";
26
-
27
- import {
28
- templateDetailSections,
29
- templateLabels,
30
- } from "../../../../lib/template-listing";
31
-
32
- interface Props {
33
- params: Promise<{ locale: string; slug: string }>;
34
- getMdxSource?: typeof defaultGetMdxSource;
35
- getPageSections?: typeof defaultGetPageSections;
36
- }
37
-
38
- type Section = Awaited<ReturnType<typeof defaultGetPageSections>>[number];
39
-
40
- export async function generateMetadata({
41
- params,
42
- }: Pick<Props, "params">): Promise<Metadata> {
43
- const { locale, slug } = await params;
44
- return renderPageMetadata({ type: "TemplatePage", slug, locale });
45
- }
46
-
47
- export default async function Page({
48
- params,
49
- getMdxSource,
50
- getPageSections,
51
- }: Props): Promise<ReactElement> {
52
- const { locale, slug } = await params;
53
- const loadSections = getPageSections ?? loadPageSections;
54
-
55
- /**
56
- * The generated sections first, then the declared ones. Runs only when a
57
- * source exists, so the translations read here never shadows renderPage's
58
- * null-source 404 (no `translationsNamespace` is passed, #7537).
59
- */
60
- async function withTemplate(frontmatter: unknown): Promise<Section[]> {
61
- const declared = await loadSections(frontmatter);
62
- const t = await getTranslations({ namespace: "templates", locale });
63
- const [hero, included] = templateDetailSections(
64
- frontmatter,
65
- templateLabels(t),
66
- );
67
- // An author's own leading hero takes the generated hero's place at the top.
68
- const [first, ...rest] = declared;
69
- return first?.type === "hero"
70
- ? [first, included, ...rest]
71
- : [hero, included, ...declared];
72
- }
73
-
74
- return renderPage({
75
- type: "TemplatePage",
76
- slug,
77
- locale,
78
- getPageSections: withTemplate,
79
- ...(getMdxSource !== undefined && { getMdxSource }),
80
- });
81
- }
@@ -1,237 +0,0 @@
1
- /**
2
- * Tests for /templates (#10051 D7, AC-4) — the TemplatesList hub.
3
- *
4
- * `renderPage`/`renderPageMetadata`/`getMdxSlugs` are mocked at the
5
- * `@working-theory/page-renderer` boundary, the /reports test shape — each
6
- * assertion inspects the sections the route hands `renderPage`. The JSON-LD
7
- * is built from those same sections with the real `buildTemplatesList`, as
8
- * `renderPage` does, so the card count and the ItemList are compared on one
9
- * input.
10
- */
11
- import { buildTemplatesList } from "@working-theory/schema";
12
-
13
- const mockRenderPage = jest.fn(async (..._args: unknown[]) => "<rendered/>");
14
- const mockRenderPageMetadata = jest.fn((..._args: unknown[]) => undefined);
15
- const mockGetMdxSlugs = jest.fn((..._args: unknown[]) =>
16
- Promise.resolve<string[]>([]),
17
- );
18
- const mockNotFound = jest.fn(() => {
19
- throw new Error("NEXT_NOT_FOUND");
20
- });
21
-
22
- jest.mock("next/navigation", () => ({
23
- __esModule: true,
24
- notFound: () => mockNotFound(),
25
- }));
26
-
27
- jest.mock("@working-theory/page-renderer", () => ({
28
- __esModule: true,
29
- getMdxSlugs: (...args: unknown[]) => mockGetMdxSlugs(...args),
30
- renderPage: (...args: unknown[]) => mockRenderPage(...args),
31
- renderPageMetadata: (...args: unknown[]) => mockRenderPageMetadata(...args),
32
- // Never reached — every call in this suite passes both via DI props.
33
- getMdxSource: jest.fn(),
34
- getPageSections: jest.fn(),
35
- }));
36
-
37
- const MESSAGES: Record<string, string> = {
38
- emptyState: "Templates coming soon.",
39
- getIt: "Get it",
40
- startFree: "Start free",
41
- viewDemo: "View demo",
42
- viewTemplate: "View template",
43
- included: "What's included",
44
- demoBadge: "Live demo",
45
- };
46
-
47
- jest.mock("next-intl/server", () => ({
48
- __esModule: true,
49
- getTranslations: () => Promise.resolve((key: string) => MESSAGES[key] ?? key),
50
- }));
51
-
52
- import TemplatesPage, { generateMetadata } from "../page";
53
-
54
- const HUB_SOURCE = {
55
- frontmatter: {
56
- type: "TemplatesList",
57
- slug: "templates",
58
- title: "Templates",
59
- description: "Every template we sell.",
60
- },
61
- body: "",
62
- };
63
-
64
- const TEMPLATE_SOURCES: Record<
65
- string,
66
- { frontmatter: Record<string, unknown>; body: string }
67
- > = {
68
- a: {
69
- frontmatter: {
70
- type: "TemplatePage",
71
- slug: "a",
72
- title: "Template A",
73
- description: "Description A.",
74
- summary: "Summary A.",
75
- price: 0,
76
- priceCurrency: "USD",
77
- demoUrl: "https://a.salessmyth.com",
78
- categories: ["accounting"],
79
- thumbnail: "/img/a.png",
80
- getItUrl: "/contact",
81
- includes: [{ title: "Base site", description: "Pages." }],
82
- },
83
- body: "",
84
- },
85
- b: {
86
- frontmatter: {
87
- type: "TemplatePage",
88
- slug: "b",
89
- title: "Template B",
90
- description: "Description B.",
91
- getItUrl: "/contact",
92
- includes: [{ title: "Base site", description: "Pages." }],
93
- },
94
- body: "",
95
- },
96
- c: {
97
- frontmatter: {
98
- type: "TemplatePage",
99
- slug: "c",
100
- title: "Template C",
101
- description: "Description C.",
102
- getItUrl: "/contact",
103
- includes: [{ title: "Base site", description: "Pages." }],
104
- },
105
- body: "",
106
- },
107
- };
108
-
109
- const CTA = { type: "cta", id: "closing", data: { headline: "Talk to us" } };
110
-
111
- function loaderFor(slugs: string[]) {
112
- mockGetMdxSlugs.mockResolvedValue([...slugs].reverse());
113
- return jest.fn(async (type: string, slug: string) => {
114
- if (type === "TemplatesList") return HUB_SOURCE;
115
- return slugs.includes(slug) ? (TEMPLATE_SOURCES[slug] ?? null) : null;
116
- });
117
- }
118
-
119
- type Section = { type: string; id: string; data: Record<string, unknown> };
120
-
121
- async function renderedSections(slugs: string[], declared: Section[] = [CTA]) {
122
- await TemplatesPage({
123
- params: Promise.resolve({ locale: "en" }),
124
- getMdxSource: loaderFor(slugs) as never,
125
- getPageSections: jest.fn(async () => declared) as never,
126
- });
127
- const input = mockRenderPage.mock.calls[0]![0] as {
128
- getPageSections: (fm: unknown) => Promise<Section[]>;
129
- };
130
- return input.getPageSections(HUB_SOURCE.frontmatter);
131
- }
132
-
133
- function cardsOf(sections: Section[]) {
134
- const grid = sections.find((s) => s.id === "template-cards");
135
- return (grid?.data.items ?? []) as Array<Record<string, unknown>>;
136
- }
137
-
138
- beforeEach(() => jest.clearAllMocks());
139
-
140
- describe("TemplatesPage — hub seed absent", () => {
141
- it("calls notFound() and never reaches renderPage", async () => {
142
- await expect(
143
- TemplatesPage({
144
- params: Promise.resolve({ locale: "en" }),
145
- getMdxSource: jest.fn().mockResolvedValue(null),
146
- getPageSections: jest.fn(),
147
- }),
148
- ).rejects.toThrow("NEXT_NOT_FOUND");
149
- expect(mockNotFound).toHaveBeenCalledTimes(1);
150
- expect(mockRenderPage).not.toHaveBeenCalled();
151
- });
152
- });
153
-
154
- describe("TemplatesPage — metadata", () => {
155
- it("resolves TemplatesList slug templates", async () => {
156
- await generateMetadata({ params: Promise.resolve({ locale: "en" }) });
157
- expect(mockRenderPageMetadata).toHaveBeenCalledWith({
158
- type: "TemplatesList",
159
- slug: "templates",
160
- locale: "en",
161
- });
162
- });
163
- });
164
-
165
- describe("TemplatesPage — the generated card grid (#10051 AC-4)", () => {
166
- it("renders TemplatesList with the templates namespace", async () => {
167
- await renderedSections(["a", "b"]);
168
- expect(mockRenderPage.mock.calls[0]![0]).toMatchObject({
169
- type: "TemplatesList",
170
- slug: "templates",
171
- translationsNamespace: "templates",
172
- });
173
- });
174
-
175
- it("renders two cards in slug order with every D2 field present", async () => {
176
- const cards = cardsOf(await renderedSections(["a", "b"]));
177
- expect(cards).toEqual([
178
- {
179
- title: "Template A",
180
- description: "Summary A.",
181
- image: { src: "/img/a.png", alt: "Template A" },
182
- eyebrow: "Accounting",
183
- badge: "Live demo",
184
- link: { label: "View template", href: "/templates/a" },
185
- },
186
- {
187
- title: "Template B",
188
- description: "Description B.",
189
- link: { label: "View template", href: "/templates/b" },
190
- },
191
- ]);
192
- });
193
-
194
- it("renders three cards when a third source is added, with no hub change", async () => {
195
- expect(cardsOf(await renderedSections(["a", "b", "c"]))).toHaveLength(3);
196
- });
197
-
198
- it("places the generated section before the seed's trailing cta", async () => {
199
- const hero = {
200
- type: "hero",
201
- id: "hub-hero",
202
- data: { headline: "Templates" },
203
- };
204
- const sections = await renderedSections(["a"], [hero, CTA]);
205
- expect(sections.map((s) => s.id)).toEqual([
206
- "hub-hero",
207
- "template-cards",
208
- "closing",
209
- ]);
210
- });
211
-
212
- it("renders the empty-state note and no card with zero sources", async () => {
213
- const sections = await renderedSections([]);
214
- expect(cardsOf(sections)).toHaveLength(0);
215
- expect(sections.find((s) => s.id === "template-cards-empty")?.data).toEqual(
216
- {
217
- body: "Templates coming soon.",
218
- align: "center",
219
- },
220
- );
221
- });
222
-
223
- it("emits an ItemList with as many elements as cards", async () => {
224
- const sections = await renderedSections(["a", "b", "c"]);
225
- // eslint-disable-next-line no-restricted-syntax -- the builder returns a loose JSON-LD node; this test reads one nested key of it
226
- const jsonLd = buildTemplatesList({
227
- type: "TemplatesList",
228
- slug: "templates",
229
- title: "Templates",
230
- description: "Every template we sell.",
231
- sections,
232
- } as never) as unknown as { mainEntity: { itemListElement: unknown[] } };
233
- expect(jsonLd.mainEntity.itemListElement).toHaveLength(
234
- cardsOf(sections).length,
235
- );
236
- });
237
- });
@@ -1,114 +0,0 @@
1
- // TemplatesList hub (#10051 D7) — the /templates page. Reads the
2
- // TemplatesList MDX via the content adapter, inserts one generated `items`
3
- // section carrying a card per TemplatePage (so the visible card grid and the
4
- // CollectionPage's ItemList JSON-LD — built from the same sections — always
5
- // agree, the /alternatives shape), and emits via the dispatcher.
6
- //
7
- // notFound() when the hub seed is absent (the /alternatives rule). With zero
8
- // TemplatePage files the generated section is a content-block carrying the
9
- // translated empty-state note (the /reports rule). Either sits before the
10
- // page's trailing closing CTA(s) (#7745 D4).
11
- //
12
- // Gated off by default (surfaces.ts `templates` surface): no roster names
13
- // this route, so a fresh scaffold excludes it. `create-ailk add-route
14
- // templates` installs it with one seed per AILK template.
15
- import type {
16
- getMdxSource as defaultGetMdxSource,
17
- getPageSections as defaultGetPageSections,
18
- } from "@working-theory/page-renderer";
19
- import {
20
- getMdxSource as loadMdxSource,
21
- getPageSections as loadPageSections,
22
- renderPage,
23
- renderPageMetadata,
24
- } from "@working-theory/page-renderer";
25
- import type { Metadata } from "next";
26
- import { notFound } from "next/navigation";
27
- import { getTranslations } from "next-intl/server";
28
- import type { ReactElement } from "react";
29
-
30
- import { honourNavOnly } from "../../../lib/hub-children";
31
- import {
32
- insertBeforeClosingCtas,
33
- listDetailPages,
34
- } from "../../../lib/route-family";
35
- import { templateCard, templateLabels } from "../../../lib/template-listing";
36
-
37
- interface Props {
38
- params: Promise<{ locale: string }>;
39
- getMdxSource?: typeof defaultGetMdxSource;
40
- getPageSections?: typeof defaultGetPageSections;
41
- }
42
-
43
- type Section = Awaited<ReturnType<typeof defaultGetPageSections>>[number];
44
-
45
- export async function generateMetadata({
46
- params,
47
- }: Pick<Props, "params">): Promise<Metadata> {
48
- const { locale } = await params;
49
- return renderPageMetadata({
50
- type: "TemplatesList",
51
- slug: "templates",
52
- locale,
53
- });
54
- }
55
-
56
- export default async function Page({
57
- params,
58
- getMdxSource,
59
- getPageSections,
60
- }: Props): Promise<ReactElement> {
61
- const { locale } = await params;
62
- const load = getMdxSource ?? loadMdxSource;
63
- const loadSections = getPageSections ?? loadPageSections;
64
-
65
- const source = await load("TemplatesList", "templates", locale);
66
- if (source === null) {
67
- notFound();
68
- }
69
-
70
- const pages = await listDetailPages("TemplatePage", locale, load);
71
- honourNavOnly(
72
- source.frontmatter,
73
- locale,
74
- pages.map((page) => `/templates/${page.slug}`),
75
- );
76
- const t = await getTranslations({ namespace: "templates", locale });
77
- const labels = templateLabels(t);
78
-
79
- /**
80
- * One generated section listing every TemplatePage — D4's "lists every
81
- * template page automatically", and the ItemList JSON-LD agrees with it
82
- * because `renderPage` builds both from these sections.
83
- */
84
- async function withTemplates(frontmatter: unknown): Promise<Section[]> {
85
- const declared = await loadSections(frontmatter);
86
- const generated: Section =
87
- pages.length > 0
88
- ? {
89
- type: "items",
90
- id: "template-cards",
91
- // A tile is one click target per card (design review round 1, B1).
92
- data: {
93
- variant: "tile",
94
- tileHover: "outline",
95
- items: pages.map((page) => templateCard(page, labels)),
96
- },
97
- }
98
- : {
99
- type: "content-block",
100
- id: "template-cards-empty",
101
- data: { body: t("emptyState"), align: "center" },
102
- };
103
- return insertBeforeClosingCtas(declared, generated);
104
- }
105
-
106
- return renderPage({
107
- type: "TemplatesList",
108
- slug: "templates",
109
- locale,
110
- translationsNamespace: "templates",
111
- getPageSections: withTemplates,
112
- ...(getMdxSource !== undefined && { getMdxSource }),
113
- });
114
- }
@@ -1,40 +0,0 @@
1
- // Terms page. Reads the TermsPage MDX frontmatter, renders sections via
2
- // SectionRenderer, and emits a JSON-LD <script>.
3
- import type {
4
- getMdxSource as defaultGetMdxSource,
5
- getPageSections as defaultGetPageSections} from "@working-theory/page-renderer";
6
- import {
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 }>;
15
- getMdxSource?: typeof defaultGetMdxSource;
16
- getPageSections?: typeof defaultGetPageSections;
17
- }
18
-
19
- export async function generateMetadata({
20
- params,
21
- }: Pick<Props, "params">): Promise<Metadata> {
22
- const { locale } = await params;
23
- return renderPageMetadata({ type: "TermsPage", slug: "terms", locale });
24
- }
25
-
26
- export default async function Page({
27
- params,
28
- getMdxSource,
29
- getPageSections,
30
- }: Props): Promise<ReactElement> {
31
- const { locale } = await params;
32
- return renderPage({
33
- type: "TermsPage",
34
- slug: "terms",
35
- locale,
36
- translationsNamespace: "terms",
37
- ...(getMdxSource !== undefined && { getMdxSource }),
38
- ...(getPageSections !== undefined && { getPageSections }),
39
- });
40
- }
@@ -1,85 +0,0 @@
1
- /**
2
- * HTML snapshot regression tests for testimonials/page.tsx → @working-theory/page-renderer migration.
3
- *
4
- * Two-commit strategy:
5
- * Commit 1: this file added; snapshots captured against pre-migration route (RED-passing).
6
- * Commit 2: route migrated; same snapshots verify diff=0 (GREEN).
7
- *
8
- * Two states tested:
9
- * - empty: getMdxSource returns null → empty-state branch
10
- * - populated: getMdxSource returns a minimal MdxPageSource → full render
11
- *
12
- * Failure = snapshot diff > 0 bytes. DO NOT regenerate snapshots to pass.
13
- */
14
- import React from "react";
15
- import { render } from "@testing-library/react";
16
-
17
- // ── @working-theory/ui mock ─────────────────────────────────────────────────────────────
18
- jest.mock("@working-theory/ui", () => ({
19
- // #7745: renderPage's mdx-body branch frames its head and body in the
20
- // section Container and renders the body through MDXContent + the shared map.
21
- Container: ({
22
- children,
23
- }: {
24
- children?: React.ReactNode;
25
- }): React.ReactElement => React.createElement("div", null, children),
26
- MDXContent: ({
27
- children,
28
- }: {
29
- children?: React.ReactNode;
30
- }): React.ReactElement => React.createElement(React.Fragment, null, children),
31
- getMDXComponents: (overrides?: Record<string, unknown>) => ({ ...overrides }),
32
- // #4446/#4447: renderPage's own fallback/empty-state title now composes
33
- // Heading (mobile type-budget classes, #4417) instead of a bare <h1>.
34
- Heading: ({
35
- children,
36
- level,
37
- }: {
38
- children: React.ReactNode;
39
- level: number;
40
- }): React.ReactElement => React.createElement(`h${level}`, null, children),
41
- SectionRenderer: ({ sections }: { sections: unknown[] }) =>
42
- React.createElement("div", {
43
- "data-testid": "section-renderer",
44
- "data-section-count": String(sections.length),
45
- }),
46
- }));
47
-
48
- import TestimonialsPage from "../page";
49
-
50
- const getMdxSourceEmpty = jest.fn().mockResolvedValue(null);
51
-
52
- describe("TestimonialsPage — snapshot regression", () => {
53
- it("empty state renders deterministic HTML", async () => {
54
- const element = await TestimonialsPage({
55
- params: Promise.resolve({ locale: "en" }),
56
- getMdxSource: getMdxSourceEmpty,
57
- });
58
- const { container } = render(element);
59
- expect(container.innerHTML).toMatchInlineSnapshot(
60
- `"<main id="main"><h1>Testimonials</h1><p data-testid="section-empty-state">Testimonials coming soon.</p></main>"`,
61
- );
62
- });
63
-
64
- it("populated state renders deterministic HTML", async () => {
65
- const source = {
66
- frontmatter: {
67
- type: "TestimonialsList" as const,
68
- slug: "testimonials",
69
- title: "Customer Testimonials",
70
- description: "What our customers say.",
71
- },
72
- body: "",
73
- };
74
- const getMdxSourcePopulated = jest.fn().mockResolvedValue(source);
75
-
76
- const element = await TestimonialsPage({
77
- params: Promise.resolve({ locale: "en" }),
78
- getMdxSource: getMdxSourcePopulated,
79
- });
80
- const { container } = render(element);
81
- expect(container.innerHTML).toMatchInlineSnapshot(
82
- `"<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@type":"CollectionPage","inLanguage":"en","name":"Customer Testimonials","description":"What our customers say.","mainEntity":{"@type":"ItemList","itemListElement":[{"@type":"Review"}]},"aggregateRating":{"@context":"https://schema.org","@type":"AggregateRating","ratingValue":4.9,"reviewCount":0,"bestRating":5,"worstRating":1,"itemReviewed":{"@type":"SoftwareApplication"}}}</script><main id="main"><div><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 data-testid="mdx-remote" data-source=""></div></article></div></div></div></main>"`,
83
- );
84
- });
85
- });
@@ -1,51 +0,0 @@
1
- // Testimonials list page. Reads TestimonialsList MDX via the content adapter and emits
2
- // a JSON-LD CollectionPage via the dispatcher.
3
- import type {
4
- getMdxSource as defaultGetMdxSource,
5
- } 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 type { ReactElement } from "react";
13
-
14
- import { honourNavOnly } from "../../../lib/hub-children";
15
-
16
- interface Props {
17
- params: Promise<{ locale: string }>;
18
- getMdxSource?: typeof defaultGetMdxSource;
19
- }
20
-
21
- export async function generateMetadata({
22
- params,
23
- }: Pick<Props, "params">): Promise<Metadata> {
24
- const { locale } = await params;
25
- return renderPageMetadata({
26
- type: "TestimonialsList",
27
- slug: "testimonials",
28
- locale,
29
- });
30
- }
31
-
32
- export default async function Page({
33
- params,
34
- getMdxSource,
35
- }: Props): Promise<ReactElement> {
36
- const { locale } = await params;
37
- const source = await (getMdxSource ?? loadMdxSource)(
38
- "TestimonialsList",
39
- "testimonials",
40
- locale,
41
- );
42
- honourNavOnly(source?.frontmatter, locale, []);
43
- return renderPage({
44
- type: "TestimonialsList",
45
- slug: "testimonials",
46
- locale,
47
- translationsNamespace: "testimonials",
48
- bodyMode: "mdx-body",
49
- ...(getMdxSource !== undefined && { getMdxSource }),
50
- });
51
- }