create-ailk 0.37.0 → 0.38.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 (232) hide show
  1. package/README.md +149 -2
  2. package/component-catalog.json +44 -6
  3. package/component-catalog.md +6 -5
  4. package/dist/add-module.js +16 -1
  5. package/dist/add-route.d.ts +7 -2
  6. package/dist/add-route.js +28 -13
  7. package/dist/cli.js +52 -0
  8. package/dist/declined-routes.d.ts +13 -0
  9. package/dist/declined-routes.js +74 -0
  10. package/dist/derive-architecture.d.ts +0 -6
  11. package/dist/derive-architecture.js +9 -15
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +3 -0
  14. package/dist/language-import.d.ts +93 -0
  15. package/dist/language-import.js +270 -43
  16. package/dist/lib/import-mdx.js +1 -1
  17. package/dist/lib/scaffold-render-sweep.d.ts +6 -3
  18. package/dist/lib/scaffold-render-sweep.js +8 -4
  19. package/dist/migrate-content.d.ts +6 -2
  20. package/dist/migrate-content.js +62 -5
  21. package/dist/module-architecture.js +139 -103
  22. package/dist/paid-sections.d.ts +13 -0
  23. package/dist/paid-sections.js +35 -5
  24. package/dist/programmatic.js +6 -16
  25. package/dist/remove-module.js +67 -0
  26. package/dist/routes.d.ts +103 -0
  27. package/dist/routes.js +708 -0
  28. package/dist/site-manifest.js +1 -1
  29. package/dist/site-roster.d.ts +2 -1
  30. package/dist/site-roster.js +30 -8
  31. package/dist/spoke-checkout.d.ts +28 -27
  32. package/dist/spoke-checkout.js +71 -102
  33. package/dist/surfaces.d.ts +18 -0
  34. package/dist/surfaces.js +47 -282
  35. package/dist/sync-routes.d.ts +28 -1
  36. package/dist/sync-routes.js +144 -11
  37. package/dist/template-record.d.ts +11 -0
  38. package/dist/template-record.js +18 -0
  39. package/dist/topology.d.ts +15 -1
  40. package/dist/topology.js +20 -4
  41. package/dist/update.d.ts +31 -2
  42. package/dist/update.js +627 -99
  43. package/package.json +3 -3
  44. package/templates/README.md +1 -1
  45. package/templates/apps/mcp/CLAUDE.md +5 -3
  46. package/templates/apps/web/CLAUDE.md +62 -20
  47. package/templates/apps/web/account.config.tsx +101 -0
  48. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
  49. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
  50. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
  51. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
  52. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
  53. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
  54. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
  55. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
  56. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
  57. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
  58. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
  59. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
  60. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
  61. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
  62. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
  63. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
  64. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
  65. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
  66. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
  67. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
  68. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
  69. package/templates/apps/web/app/[locale]/layout.tsx +45 -28
  70. package/templates/apps/web/app/apple-icon.tsx +72 -0
  71. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  72. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  73. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  74. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  75. package/templates/apps/web/app/og/route.tsx +155 -72
  76. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  77. package/templates/apps/web/i18n/request.ts +44 -1
  78. package/templates/apps/web/jest.config.cjs +13 -1
  79. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  80. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
  81. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  82. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  83. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  84. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  85. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  86. package/templates/apps/web/lib/listings.tsx +2 -2
  87. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  88. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  89. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  90. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  91. package/templates/apps/web/lib/served-pages.ts +95 -0
  92. package/templates/apps/web/lib/site-brand.tsx +3 -5
  93. package/templates/apps/web/messages/en.json +8 -684
  94. package/templates/apps/web/middleware.ts +3 -1
  95. package/templates/apps/web/next.config.mjs +27 -0
  96. package/templates/apps/web/package.json +1 -0
  97. package/templates/customizations.yaml +9 -0
  98. package/templates/package.json +3 -1
  99. package/templates/tools/lint-architecture.ts +164 -11
  100. package/versions.json +48 -47
  101. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  102. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  103. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  104. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  105. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  106. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  107. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  108. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  109. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  110. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  111. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  112. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  113. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  114. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  115. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  116. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  117. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  118. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  119. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  120. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  121. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  122. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  123. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  124. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  125. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  126. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  127. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  128. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  129. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  130. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  131. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  132. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  133. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  134. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  135. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  136. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  137. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  138. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  139. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  140. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  141. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  142. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  143. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  144. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  145. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  146. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  147. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  148. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  149. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  150. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  151. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  152. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  153. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  154. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  155. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  156. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  157. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  158. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  159. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  160. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  161. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  162. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  163. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  164. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  165. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  166. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  167. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  168. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  169. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  170. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  171. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  172. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  173. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  174. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  175. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  176. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  177. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  178. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  179. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  180. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  181. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  182. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  183. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  184. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  185. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  186. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  187. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  188. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  189. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  190. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  191. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  192. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  193. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  194. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  195. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  196. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  197. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  198. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  199. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  200. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  201. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  202. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  203. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  204. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  205. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  206. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  207. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  208. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  209. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  210. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  211. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  212. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  213. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  214. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  215. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  216. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  217. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  218. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  219. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  220. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  221. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  222. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  223. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  224. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  225. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  226. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  227. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  228. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  229. package/templates/apps/web/lib/account-config.ts +0 -678
  230. package/templates/apps/web/lib/checkout-config.ts +0 -16
  231. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  232. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
@@ -1,51 +1,124 @@
1
1
  /**
2
- * The back arrow's href on a team profile page (#7744 D7).
2
+ * The bare header's back arrow: where it goes and what it is called
3
+ * (operator handoff 2026-11-09, superseding #7744 D7's people-slide rule).
3
4
  *
4
- * On a deck home, a profile at `/team/<slug>` returns the visitor to the
5
- * home's people slide — `#slide-people`, the anchor #7740 gives the home
6
- * section whose id is `people` — rather than to the top of the home
7
- * (checklist D3). Every other inner page, the `/team` index included, and
8
- * every page on a non-deck home goes home.
5
+ * The arrow goes to the page's PARENT — the path with its last segment
6
+ * dropped, the locale prefix kept (`/meet/discovery` → `/meet`,
7
+ * `/es/meet/discovery` → `/es/meet`). A parent the site does not serve is
8
+ * skipped and the walk goes up again; past the top it is the home, so a
9
+ * top-level page's arrow still goes home and the arrow never links a 404.
10
+ *
11
+ * The return to the slide a visitor left from is not decided here: it is
12
+ * `@working-theory/ui`'s `NavBackLink` + `deck-return.ts` (#8644), which
13
+ * rewrites this href client-side on a matching arrival from a deck, whatever
14
+ * this href is. A direct arrival keeps the parent computed here.
9
15
  *
10
16
  * No Next.js import — pure functions, asserted directly by their own suite,
11
17
  * in the `auth-routes.ts` idiom.
12
18
  */
13
19
 
14
- /** The people slide's anchor: #7740's `slide-` prefix plus the section id `people`. */
15
- export const PEOPLE_SLIDE_ANCHOR = "slide-people";
20
+ /** `pathname` without its query, hash, trailing slash and enabled-locale prefix. */
21
+ function barePath(pathname: string, locales: readonly string[]): string {
22
+ // Trailing slashes trimmed by a loop, not an anchored `/\/+$/`: the header
23
+ // can be client-set, and that regex backtracks quadratically on a long run.
24
+ let path = pathname.split(/[?#]/)[0] ?? "";
25
+ let end = path.length;
26
+ while (end > 0 && path[end - 1] === "/") end--;
27
+ path = path.slice(0, end);
28
+ const bare =
29
+ locales.length > 0
30
+ ? path.replace(new RegExp(`^/(${locales.map(escapeRegExp).join("|")})(?=/|$)`), "")
31
+ : path;
32
+ return bare === "" ? "/" : bare;
33
+ }
34
+
35
+ function escapeRegExp(segment: string): string {
36
+ return segment.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
37
+ }
16
38
 
17
39
  /**
18
- * Whether `pathname` is a team profile: `/team/<slug>`, bare or under an
19
- * enabled-locale prefix. Not `/team` (the index) and not a deeper path.
40
+ * The page's served parent as a bare (locale-less) path, nearest first, or
41
+ * `null` when no ancestor below the home is served.
20
42
  *
21
- * Fail-safe direction: an absent or empty pathname answers `false`, so a
22
- * missing `x-pathname` header leaves the back arrow pointing home.
43
+ * Fail-safe direction: an absent or empty pathname answers `null`, so a
44
+ * missing `x-pathname` header leaves the arrow pointing home.
23
45
  */
24
- export function isTeamProfilePath(
25
- pathname: string | null | undefined,
26
- locales: readonly string[],
27
- ): boolean {
28
- if (!pathname) return false;
29
- const path = pathname.split(/[?#]/)[0] ?? "";
30
- const bare =
31
- locales.length > 0
32
- ? path.replace(new RegExp(`^/(${locales.join("|")})(?=/|$)`), "")
33
- : path;
34
- const segments = bare.split("/").slice(1);
35
- return (
36
- segments.length === 2 && segments[0] === "team" && segments[1] !== ""
37
- );
46
+ export function servedParent(input: {
47
+ pathname: string | null | undefined;
48
+ locales: readonly string[];
49
+ served: (barePath: string) => boolean;
50
+ }): string | null {
51
+ const { pathname, locales, served } = input;
52
+ if (!pathname) return null;
53
+ const segments = barePath(pathname, locales).split("/").filter(Boolean);
54
+ for (let depth = segments.length - 1; depth >= 1; depth--) {
55
+ const parent = `/${segments.slice(0, depth).join("/")}`;
56
+ if (served(parent)) return parent;
57
+ }
58
+ return null;
38
59
  }
39
60
 
40
- /** `${homePath}#slide-people` when the home is a deck and the path is a profile; otherwise `homePath`. */
61
+ /** The arrow's server href: the served parent under the home's locale prefix, else `homePath`. */
41
62
  export function backLinkHref(input: {
42
63
  pathname: string | null | undefined;
43
64
  homePath: string;
44
- home: string;
45
65
  locales: readonly string[];
66
+ served: (barePath: string) => boolean;
46
67
  }): string {
47
- const { pathname, homePath, home, locales } = input;
48
- return home === "deck" && isTeamProfilePath(pathname, locales)
49
- ? `${homePath}#${PEOPLE_SLIDE_ANCHOR}`
50
- : homePath;
68
+ return parentHref(servedParent(input), input.homePath);
69
+ }
70
+
71
+ /** A bare parent under the home's locale prefix; `homePath` itself for no parent. */
72
+ export function parentHref(parent: string | null, homePath: string): string {
73
+ if (parent === null) return homePath;
74
+ return homePath === "/" ? parent : `${homePath}${parent}`;
75
+ }
76
+
77
+ /**
78
+ * Path → label for every `{ labelKey, path }` entry anywhere in the nav and
79
+ * footer configs (flyout features, groups, columns), first entry winning.
80
+ * Every such path is a route the site carries (`lib/nav-config.ts`).
81
+ */
82
+ export function navLabelsByPath(
83
+ nodes: unknown,
84
+ labelFor: (key: string) => string,
85
+ ): Map<string, string> {
86
+ const labels = new Map<string, string>();
87
+ const visit = (node: unknown): void => {
88
+ if (Array.isArray(node)) {
89
+ node.forEach(visit);
90
+ return;
91
+ }
92
+ if (typeof node !== "object" || node === null) return;
93
+ const entry = node as Record<string, unknown>;
94
+ if (
95
+ typeof entry.path === "string" &&
96
+ typeof entry.labelKey === "string" &&
97
+ !labels.has(entry.path)
98
+ ) {
99
+ labels.set(entry.path, labelFor(entry.labelKey));
100
+ }
101
+ Object.values(entry).forEach(visit);
102
+ };
103
+ visit(nodes);
104
+ return labels;
105
+ }
106
+
107
+ /**
108
+ * The name the arrow's label gives its destination ("Back to <name>"): the
109
+ * parent's nav label, else its page title, else its last segment in words
110
+ * (`/meet` → "Meet", `/case-studies` → "Case studies"), so the label always
111
+ * names where the link goes.
112
+ */
113
+ export function backLinkName(
114
+ parent: string,
115
+ sources: {
116
+ navLabels: ReadonlyMap<string, string>;
117
+ titles: ReadonlyMap<string, string>;
118
+ },
119
+ ): string {
120
+ const named = sources.navLabels.get(parent) || sources.titles.get(parent);
121
+ if (named) return named;
122
+ const words = (parent.split("/").pop() ?? "").replace(/-/g, " ");
123
+ return words.charAt(0).toUpperCase() + words.slice(1);
51
124
  }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * The site's served pages for one locale, as bare (locale-less) path → page
3
+ * title — what the bare header's back arrow walks up through
4
+ * (operator handoff 2026-11-09, `lib/profile-back-link.ts`).
5
+ *
6
+ * Two sources, each one this app already serves from:
7
+ * 1. Every content page the sitemap lists, at the path it lists it at
8
+ * (`app/sitemap.xml/route.ts`: `listPages` per type, `listedPath` over
9
+ * the site's listing, docs rows and `ThankYouPage` left out). Title =
10
+ * the page's frontmatter `title`.
11
+ * 2. Every fixed, code-rendered route in the routes map (`ROUTES` rows with
12
+ * no `:` segment and no `contentPath`) whose module's pages this site
13
+ * carries (`lib/modules.generated.ts`) — `/meet` is one: its index is
14
+ * code, its seeds are detail pages. No title.
15
+ * A route with seed content counts only through source 1, so a scaffold
16
+ * that dropped that surface's content never gets a link to a missing page.
17
+ * The layout adds the nav and footer paths itself (every nav entry is a
18
+ * route the site carries — `lib/nav-config.ts`).
19
+ *
20
+ * Shared per server instance for 60 seconds per locale, and fail-safe: any
21
+ * read that throws leaves that source out, so the arrow degrades toward the
22
+ * home, never to an error.
23
+ */
24
+
25
+ import { SCHEMA_ORG_TYPES } from "@working-theory/content-adapters";
26
+ import type { SchemaOrgType } from "@working-theory/content-adapters";
27
+ import { getContentAdapter, listedPath } from "@working-theory/page-renderer";
28
+ import { ROUTES } from "@working-theory/templates/routes";
29
+
30
+ import { pagePathFor } from "../src/lib/routes";
31
+
32
+ import { isDocsType } from "./docs-index";
33
+ import {
34
+ DOCS_BLOG_PAGES,
35
+ MARKETING_PAGES,
36
+ SCHEDULING_PAGES,
37
+ } from "./modules.generated";
38
+ import { SITE_LISTING } from "./site-listing";
39
+
40
+ const TTL_MS = 60_000;
41
+
42
+ /** The modules whose code-rendered pages a site may carry, by its generated flags. */
43
+ const MODULE_PAGES: Readonly<Record<string, boolean>> = {
44
+ marketing: MARKETING_PAGES,
45
+ scheduling: SCHEDULING_PAGES,
46
+ "docs-blog": DOCS_BLOG_PAGES,
47
+ };
48
+
49
+ const cache = new Map<
50
+ string,
51
+ { at: number; pages: Promise<ReadonlyMap<string, string>> }
52
+ >();
53
+
54
+ async function readServedPages(
55
+ locale: string,
56
+ ): Promise<ReadonlyMap<string, string>> {
57
+ const pages = new Map<string, string>();
58
+
59
+ for (const row of ROUTES) {
60
+ if (row.route.includes(":") || row.contentPath !== undefined) continue;
61
+ if (MODULE_PAGES[row.module] !== true) continue;
62
+ pages.set(row.route, "");
63
+ }
64
+
65
+ try {
66
+ const adapter = getContentAdapter();
67
+ const types = SCHEMA_ORG_TYPES as readonly SchemaOrgType[];
68
+ const lists = await Promise.all(
69
+ types.map((type) => adapter.listPages(type, locale).catch(() => [])),
70
+ );
71
+ for (const list of lists) {
72
+ for (const page of list) {
73
+ if (isDocsType(page.type) || page.type === "ThankYouPage") continue;
74
+ const path = listedPath(SITE_LISTING, page, pagePathFor);
75
+ if (path !== null) pages.set(path, page.title);
76
+ }
77
+ }
78
+ } catch {
79
+ // No adapter: the code-rendered routes alone.
80
+ }
81
+
82
+ return pages;
83
+ }
84
+
85
+ /** Bare path → title ("" when the page has none) for every page served in `locale`. */
86
+ export function servedPages(
87
+ locale: string,
88
+ ): Promise<ReadonlyMap<string, string>> {
89
+ const now = Date.now();
90
+ const hit = cache.get(locale);
91
+ if (hit && now - hit.at < TTL_MS) return hit.pages;
92
+ const pages = readServedPages(locale);
93
+ cache.set(locale, { at: now, pages });
94
+ return pages;
95
+ }
@@ -120,11 +120,9 @@ function readSiteFrontmatter(): SiteFrontmatter | null {
120
120
  }
121
121
 
122
122
  // Read once at module init — mirrors the existing SITE_NAME contract (a
123
- // plain constant, not a function), and every consumer of this module already
124
- // runs in the Node.js runtime (no `content/` access exists in the Edge
125
- // runtime, so `app/og/route.tsx` — the one Edge-runtime consumer among the
126
- // #4157 sites — deliberately does NOT import this module; see its own
127
- // comment).
123
+ // plain constant, not a function). Every consumer of this module runs in the
124
+ // Node.js runtime, since `content/` is not readable from the Edge runtime —
125
+ // `app/og/route.tsx` included, which moved to Node to read the brand (#11244).
128
126
  const siteFrontmatter = readSiteFrontmatter();
129
127
 
130
128
  export const SITE_NAME =