create-ailk 0.39.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/add-route.js +15 -0
- package/dist/body-heading.d.ts +2 -1
- package/dist/body-heading.js +31 -3
- package/dist/module-architecture.js +0 -3
- package/dist/remove-module.js +13 -4
- package/dist/routes.d.ts +7 -0
- package/dist/routes.js +1 -1
- package/dist/site-roster.js +7 -1
- package/dist/surfaces.d.ts +2 -0
- package/dist/surfaces.js +59 -172
- package/package.json +3 -3
- package/templates/apps/web/CLAUDE.md +7 -1
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +3 -2
- package/templates/apps/web/__tests__/__mocks__/next-intl.ts +3 -2
- package/templates/apps/web/app/[locale]/layout.tsx +1 -1
- package/templates/apps/web/i18n/request.ts +5 -1
- package/templates/apps/web/jest.config.cjs +6 -0
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +9 -0
- package/templates/apps/web/lib/__tests__/in-page-magnet-self-request.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +2 -2
- package/templates/apps/web/lib/__tests__/pricing-page.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
- package/templates/apps/web/lib/in-page-magnet.ts +2 -2
- package/templates/apps/web/lib/pricing-page.ts +3 -3
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +1 -1
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +1 -1
- package/templates/apps/web/lib/site-header.ts +1 -1
- package/templates/apps/web/messages/en.json +0 -119
- package/templates/apps/web/next.config.mjs +7 -0
- package/templates/apps/web/package.json +1 -0
- package/templates/apps/web/site-pages.config.tsx +85 -0
- package/templates/tools/body-heading.ts +30 -3
- package/versions.json +50 -49
- package/templates/apps/web/app/[locale]/(authed)/leads/__tests__/page.test.tsx +0 -205
- package/templates/apps/web/app/[locale]/(authed)/leads/components/LeadsTable.tsx +0 -137
- package/templates/apps/web/app/[locale]/(authed)/leads/page.tsx +0 -122
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ForbiddenState.tsx +0 -24
- package/templates/apps/web/app/[locale]/(authed)/waitlist/format.ts +0 -111
- package/templates/apps/web/app/[locale]/[slug]/[detail]/__tests__/page.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/[slug]/[detail]/page.tsx +0 -143
- package/templates/apps/web/app/[locale]/[slug]/__tests__/page.test.tsx +0 -148
- package/templates/apps/web/app/[locale]/[slug]/page.tsx +0 -109
- package/templates/apps/web/app/[locale]/about/[slug]/page.tsx +0 -46
- package/templates/apps/web/app/[locale]/about/__tests__/about-routes.test.tsx +0 -353
- package/templates/apps/web/app/[locale]/about/page.tsx +0 -122
- package/templates/apps/web/app/[locale]/alternatives/__tests__/page.test.tsx +0 -161
- package/templates/apps/web/app/[locale]/alternatives/page.tsx +0 -112
- package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +0 -244
- package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +0 -325
- package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +0 -120
- package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +0 -73
- package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +0 -497
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +0 -172
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +0 -153
- package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +0 -141
- package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +0 -546
- package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +0 -189
- package/templates/apps/web/app/[locale]/careers/page.tsx +0 -165
- package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/case-studies/__tests__/hub-children.test.tsx +0 -65
- package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +0 -125
- package/templates/apps/web/app/[locale]/case-studies/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +0 -85
- package/templates/apps/web/app/[locale]/clients/page.tsx +0 -47
- package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +0 -249
- package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +0 -400
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-magnet.test.ts +0 -138
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-text.test.ts +0 -49
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +0 -494
- package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +0 -1122
- package/templates/apps/web/app/[locale]/contact/__tests__/intake-analytics.test.ts +0 -51
- package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +0 -319
- package/templates/apps/web/app/[locale]/contact/contact-form-magnet.ts +0 -77
- package/templates/apps/web/app/[locale]/contact/contact-form-text.ts +0 -52
- package/templates/apps/web/app/[locale]/contact/contact.actions.ts +0 -403
- package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +0 -49
- package/templates/apps/web/app/[locale]/contact/intake-script.ts +0 -92
- package/templates/apps/web/app/[locale]/contact/page.tsx +0 -267
- package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/courses/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +0 -123
- package/templates/apps/web/app/[locale]/courses/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +0 -57
- package/templates/apps/web/app/[locale]/events/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +0 -164
- package/templates/apps/web/app/[locale]/events/__tests__/program-event.test.tsx +0 -120
- package/templates/apps/web/app/[locale]/events/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/faq/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/features/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/features/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/features/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/for/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/for/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/for/__tests__/page-renderer-migration.test.tsx +0 -90
- package/templates/apps/web/app/[locale]/for/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/glossary/page.tsx +0 -53
- package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +0 -78
- package/templates/apps/web/app/[locale]/how-to/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/integrations/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/integrations/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/launch-service/page.tsx +0 -44
- package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +0 -236
- package/templates/apps/web/app/[locale]/newsletter/page.tsx +0 -179
- package/templates/apps/web/app/[locale]/page.tsx +0 -147
- package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +0 -45
- package/templates/apps/web/app/[locale]/partners/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +0 -125
- package/templates/apps/web/app/[locale]/partners/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/portfolio/[slug]/page.tsx +0 -46
- package/templates/apps/web/app/[locale]/portfolio/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/portfolio/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/pricing/[slug]/__tests__/page.test.tsx +0 -324
- package/templates/apps/web/app/[locale]/pricing/[slug]/page.tsx +0 -87
- package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +0 -7
- package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +0 -605
- package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +0 -219
- package/templates/apps/web/app/[locale]/pricing/__tests__/pricing-pages.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +0 -282
- package/templates/apps/web/app/[locale]/pricing/page.tsx +0 -120
- package/templates/apps/web/app/[locale]/privacy/page.tsx +0 -40
- package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/products/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/products/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +0 -37
- package/templates/apps/web/app/[locale]/projects/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +0 -157
- package/templates/apps/web/app/[locale]/projects/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/purchase-policy/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/resources/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +0 -151
- package/templates/apps/web/app/[locale]/resources/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/services/[slug]/[child]/page.tsx +0 -68
- package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +0 -88
- package/templates/apps/web/app/[locale]/services/__tests__/hub-children.test.tsx +0 -158
- package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +0 -187
- package/templates/apps/web/app/[locale]/services/__tests__/service-detail-sections.test.tsx +0 -224
- package/templates/apps/web/app/[locale]/services/__tests__/service-families.test.tsx +0 -368
- package/templates/apps/web/app/[locale]/services/page.tsx +0 -71
- package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +0 -81
- package/templates/apps/web/app/[locale]/software/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/team/[slug]/page.tsx +0 -45
- package/templates/apps/web/app/[locale]/team/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +0 -161
- package/templates/apps/web/app/[locale]/team/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +0 -82
- package/templates/apps/web/app/[locale]/tech-articles/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/templates/[slug]/__tests__/page.test.tsx +0 -203
- package/templates/apps/web/app/[locale]/templates/[slug]/page.tsx +0 -81
- package/templates/apps/web/app/[locale]/templates/__tests__/page.test.tsx +0 -237
- package/templates/apps/web/app/[locale]/templates/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/terms/page.tsx +0 -40
- package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +0 -85
- package/templates/apps/web/app/[locale]/testimonials/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +0 -136
- package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +0 -39
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +0 -226
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +0 -217
- package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +0 -106
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +0 -94
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe.actions.ts +0 -55
- package/templates/apps/web/app/[locale]/vs/[slug]/__tests__/page.test.tsx +0 -100
- package/templates/apps/web/app/[locale]/vs/[slug]/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +0 -82
- package/templates/apps/web/app/[locale]/whitepapers/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/working-agreement/__tests__/page.test.tsx +0 -63
- package/templates/apps/web/app/[locale]/working-agreement/page.tsx +0 -41
- package/templates/apps/web/lib/__tests__/hub-children.fixtures.ts +0 -279
- package/templates/apps/web/lib/__tests__/route-family.test.ts +0 -57
- package/templates/apps/web/lib/__tests__/service-listing.test.ts +0 -111
- package/templates/apps/web/lib/__tests__/template-listing.test.ts +0 -158
- package/templates/apps/web/lib/hub-children.tsx +0 -351
- package/templates/apps/web/lib/meet-placeholder.ts +0 -5
- package/templates/apps/web/lib/posting-title.ts +0 -39
- package/templates/apps/web/lib/route-family.ts +0 -69
- package/templates/apps/web/lib/service-listing.ts +0 -89
- package/templates/apps/web/lib/template-listing.ts +0 -169
- package/templates/apps/web/src/lib/__tests__/lead-write.test.ts +0 -187
- package/templates/apps/web/src/lib/lead-write.ts +0 -90
- /package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +0 -0
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// Integrations list page. Reads IntegrationsList MDX via the content adapter and
|
|
2
|
-
// emits a JSON-LD CollectionPage via the dispatcher.
|
|
3
|
-
// It lists every Integration page through one generated card section (#10121,
|
|
4
|
-
// apps/web/lib/hub-children.tsx — the /alternatives and /templates shape).
|
|
5
|
-
import type {
|
|
6
|
-
getMdxSlugs as defaultGetMdxSlugs,
|
|
7
|
-
getMdxSource as defaultGetMdxSource,
|
|
8
|
-
getPageSections as defaultGetPageSections,
|
|
9
|
-
} from "@working-theory/page-renderer";
|
|
10
|
-
import { renderPage, renderPageMetadata } from "@working-theory/page-renderer";
|
|
11
|
-
import type { Metadata } from "next";
|
|
12
|
-
import type { ReactElement } from "react";
|
|
13
|
-
|
|
14
|
-
import { type HubConfig, hubPageInput } from "../../../lib/hub-children";
|
|
15
|
-
|
|
16
|
-
interface Props {
|
|
17
|
-
params: Promise<{ locale: string }>;
|
|
18
|
-
getMdxSource?: typeof defaultGetMdxSource;
|
|
19
|
-
getPageSections?: typeof defaultGetPageSections;
|
|
20
|
-
getMdxSlugs?: typeof defaultGetMdxSlugs;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const HUB: HubConfig = {
|
|
24
|
-
listType: "IntegrationsList",
|
|
25
|
-
slug: "integrations",
|
|
26
|
-
childType: "Integration",
|
|
27
|
-
linkLabel: "View the integration",
|
|
28
|
-
sectionId: "integration-cards",
|
|
29
|
-
body: "mdx-body",
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export async function generateMetadata({
|
|
33
|
-
params,
|
|
34
|
-
}: Pick<Props, "params">): Promise<Metadata> {
|
|
35
|
-
const { locale } = await params;
|
|
36
|
-
return renderPageMetadata({ type: "IntegrationsList", slug: "integrations", locale });
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default async function Page({
|
|
40
|
-
params,
|
|
41
|
-
...loaders
|
|
42
|
-
}: Props): Promise<ReactElement> {
|
|
43
|
-
const { locale } = await params;
|
|
44
|
-
return renderPage({
|
|
45
|
-
type: "IntegrationsList",
|
|
46
|
-
slug: "integrations",
|
|
47
|
-
...(await hubPageInput(HUB, locale, loaders)),
|
|
48
|
-
});
|
|
49
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// Launch Service page. Reads the Service/launch-service MDX frontmatter,
|
|
2
|
-
// renders sections via 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({
|
|
24
|
-
type: "Service",
|
|
25
|
-
slug: "launch-service",
|
|
26
|
-
locale,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default async function Page({
|
|
31
|
-
params,
|
|
32
|
-
getMdxSource,
|
|
33
|
-
getPageSections,
|
|
34
|
-
}: Props): Promise<ReactElement> {
|
|
35
|
-
const { locale } = await params;
|
|
36
|
-
return renderPage({
|
|
37
|
-
type: "Service",
|
|
38
|
-
slug: "launch-service",
|
|
39
|
-
locale,
|
|
40
|
-
translationsNamespace: "launch-service",
|
|
41
|
-
...(getMdxSource !== undefined && { getMdxSource }),
|
|
42
|
-
...(getPageSections !== undefined && { getPageSections }),
|
|
43
|
-
});
|
|
44
|
-
}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* newsletter/page.tsx — the newsletter magnet is the only source (#8847 D11,
|
|
3
|
-
* AC-6), and a signup only when there is somewhere to keep it (#6730 D9).
|
|
4
|
-
*
|
|
5
|
-
* Renders the REAL `NewsletterFormInline` and binds the REAL
|
|
6
|
-
* `subscribeNewsletterAction`. Mocked boundaries: `@working-theory/api-client`
|
|
7
|
-
* (`flows.get`, `flows.submitStep`, `leads.captureStatus`, `leads.subscribe`),
|
|
8
|
-
* `next/headers`, `next-intl/server` (over the real English catalog), the
|
|
9
|
-
* `_site.mdx` contact-email read, and the page-renderer's content loaders
|
|
10
|
-
* (injected).
|
|
11
|
-
*/
|
|
12
|
-
import React from "react";
|
|
13
|
-
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
14
|
-
import { newsletterFlowConfig, type FlowConfig } from "@working-theory/validation";
|
|
15
|
-
|
|
16
|
-
jest.mock("next/navigation", () => ({
|
|
17
|
-
__esModule: true,
|
|
18
|
-
notFound: jest.fn(() => {
|
|
19
|
-
throw new Error("NEXT_NOT_FOUND");
|
|
20
|
-
}),
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
jest.mock("next-mdx-remote/rsc", () => ({
|
|
24
|
-
__esModule: true,
|
|
25
|
-
MDXRemote: ({ source }: { source: string }) =>
|
|
26
|
-
React.createElement("div", { "data-testid": "mdx-rendered" }, source),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
jest.mock("@working-theory/api-client", () => ({
|
|
30
|
-
flows: { get: jest.fn(), submitStep: jest.fn() },
|
|
31
|
-
leads: { captureStatus: jest.fn(), submit: jest.fn(), subscribe: jest.fn() },
|
|
32
|
-
visitorForwardHeaders: () => undefined,
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
jest.mock("next/headers", () => ({
|
|
36
|
-
__esModule: true,
|
|
37
|
-
headers: jest.fn().mockResolvedValue({ get: () => null }),
|
|
38
|
-
cookies: jest.fn().mockResolvedValue({ get: () => undefined }),
|
|
39
|
-
}));
|
|
40
|
-
|
|
41
|
-
// The real English catalog, so the page's own strings render as they ship.
|
|
42
|
-
jest.mock("next-intl/server", () => {
|
|
43
|
-
const messages = jest.requireActual("../../../../messages/en.json") as Record<
|
|
44
|
-
string,
|
|
45
|
-
Record<string, unknown>
|
|
46
|
-
>;
|
|
47
|
-
return {
|
|
48
|
-
getLocale: async () => "en",
|
|
49
|
-
getTranslations: async (arg: string | { namespace: string }) => {
|
|
50
|
-
const ns = messages[typeof arg === "string" ? arg : arg.namespace] ?? {};
|
|
51
|
-
return (key: string, values?: Record<string, string>) =>
|
|
52
|
-
String(ns[key] ?? key).replace(/\{(\w+)\}/g, (m, name: string) => values?.[name] ?? m);
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// eslint-disable-next-line no-restricted-syntax -- test-seam mock: the real read is a node:fs frontmatter parse of content/_site.mdx; narrowest possible scope
|
|
58
|
-
jest.mock("../../contact/site-contact-email", () => ({
|
|
59
|
-
readSiteContactEmail: jest.fn().mockReturnValue("hi@x.co"),
|
|
60
|
-
}));
|
|
61
|
-
|
|
62
|
-
import { flows, leads } from "@working-theory/api-client";
|
|
63
|
-
|
|
64
|
-
import * as pageModule from "../page";
|
|
65
|
-
import NewsletterPage from "../page";
|
|
66
|
-
|
|
67
|
-
const mockFlowsGet = flows.get as jest.Mock;
|
|
68
|
-
const mockSubmitStep = flows.submitStep as jest.Mock;
|
|
69
|
-
const mockCaptureStatus = leads.captureStatus as jest.Mock;
|
|
70
|
-
|
|
71
|
-
const status = (newsletter: boolean) => ({
|
|
72
|
-
ok: true,
|
|
73
|
-
status: 200,
|
|
74
|
-
body: { ok: true, data: { contact: true, newsletter } },
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
/** The served magnet: the stored config minus its completion email. */
|
|
78
|
-
function served(config: FlowConfig) {
|
|
79
|
-
const { completionEmail: _omitted, ...body } = config;
|
|
80
|
-
return { ok: true, status: 200, body };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const source = {
|
|
84
|
-
frontmatter: {
|
|
85
|
-
type: "NewsletterSignup" as const,
|
|
86
|
-
slug: "newsletter",
|
|
87
|
-
title: "{Newsletter}",
|
|
88
|
-
description: "What subscribers get.",
|
|
89
|
-
},
|
|
90
|
-
body: "",
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/** The starter's seed (#8847 D14): one column contact-form section. */
|
|
94
|
-
const STARTER_SECTIONS = [
|
|
95
|
-
{ id: "signup", type: "contact-form", data: { variant: "column", fields: [] } },
|
|
96
|
-
];
|
|
97
|
-
|
|
98
|
-
/** `_base`'s pre-#8847 content: a hero whose CTA points at `#signup`, the signup section, an FAQ. */
|
|
99
|
-
const LEGACY_SECTIONS = [
|
|
100
|
-
{ id: "hero", type: "hero", data: { headline: "News", primaryCta: { label: "Subscribe", href: "#signup" } } },
|
|
101
|
-
{ id: "signup", type: "newsletter", data: { action: "/v1/leads/subscribe", source: "newsletter" } },
|
|
102
|
-
{ id: "faq", type: "faq", data: { items: [] } },
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
async function renderWith(sections: unknown[]) {
|
|
106
|
-
const element = await NewsletterPage({
|
|
107
|
-
params: Promise.resolve({ locale: "en" }),
|
|
108
|
-
getMdxSource: jest.fn().mockResolvedValue(source),
|
|
109
|
-
getPageSections: jest.fn().mockResolvedValue(sections),
|
|
110
|
-
});
|
|
111
|
-
return render(element);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// The page shares its hub reads for a few seconds, per module instance. Each
|
|
115
|
-
// test starts an hour later so none sees another's read.
|
|
116
|
-
let clock = 1_900_000_000_000;
|
|
117
|
-
jest.spyOn(Date, "now").mockImplementation(() => clock);
|
|
118
|
-
|
|
119
|
-
beforeEach(() => {
|
|
120
|
-
jest.clearAllMocks();
|
|
121
|
-
clock += 60 * 60 * 1000;
|
|
122
|
-
mockCaptureStatus.mockResolvedValue(status(true));
|
|
123
|
-
mockFlowsGet.mockResolvedValue(served(newsletterFlowConfig));
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
describe("NewsletterPage — the newsletter magnet (#8847 AC-6)", () => {
|
|
127
|
-
it("is rendered on every request, never ISR", () => {
|
|
128
|
-
expect(pageModule.dynamic).toBe("force-dynamic");
|
|
129
|
-
expect("revalidate" in pageModule).toBe(false);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("the H1, label, consent and help line are the magnet's; no upsell", async () => {
|
|
133
|
-
await renderWith(STARTER_SECTIONS);
|
|
134
|
-
|
|
135
|
-
expect(mockFlowsGet).toHaveBeenCalledWith("newsletter");
|
|
136
|
-
const headings = screen.getAllByRole("heading", { level: 1 });
|
|
137
|
-
expect(headings).toHaveLength(1);
|
|
138
|
-
expect(headings[0]).toHaveTextContent("Get the newsletter");
|
|
139
|
-
expect(document.body).toHaveTextContent("One email when there is something new.");
|
|
140
|
-
expect(screen.getByText("Email")).not.toHaveClass("sr-only");
|
|
141
|
-
const statement = screen.getByTestId("newsletter-consent-statement");
|
|
142
|
-
expect(statement).toHaveTextContent("I accept the Terms and Privacy Policy.");
|
|
143
|
-
expect(statement.querySelector("a[href='/terms']")).not.toBeNull();
|
|
144
|
-
expect(statement.querySelector("a[href='/privacy']")).not.toBeNull();
|
|
145
|
-
expect(screen.getByTestId("newsletter-help")).toHaveTextContent("No spam. Unsubscribe any time.");
|
|
146
|
-
expect(screen.getByTestId("newsletter-submit")).toHaveTextContent("Subscribe");
|
|
147
|
-
for (const upsell of ["Substack", "Pro", "ailaunchkit.ai"]) {
|
|
148
|
-
expect(document.body).not.toHaveTextContent(upsell);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it("generateMetadata's title is the magnet's step title", async () => {
|
|
153
|
-
const metadata = await pageModule.generateMetadata({
|
|
154
|
-
params: Promise.resolve({ locale: "en" }),
|
|
155
|
-
getMdxSource: jest.fn().mockResolvedValue(source),
|
|
156
|
-
getPageSections: jest.fn().mockResolvedValue(STARTER_SECTIONS),
|
|
157
|
-
});
|
|
158
|
-
expect(String((metadata.title as { absolute?: string })?.absolute ?? metadata.title)).toContain(
|
|
159
|
-
"Get the newsletter",
|
|
160
|
-
);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it("a signup goes through the magnet and the ending replaces the form", async () => {
|
|
164
|
-
mockSubmitStep.mockResolvedValue({
|
|
165
|
-
ok: true,
|
|
166
|
-
status: 200,
|
|
167
|
-
body: { sessionId: "s1", nextStepKey: null, completed: true },
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
await renderWith(STARTER_SECTIONS);
|
|
171
|
-
fireEvent.change(screen.getByTestId("newsletter-email-input"), { target: { value: "a@b.co" } });
|
|
172
|
-
fireEvent.click(screen.getByTestId("newsletter-consent-checkbox"));
|
|
173
|
-
await act(async () => {
|
|
174
|
-
fireEvent.submit(screen.getByTestId("newsletter-form"));
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
await waitFor(() =>
|
|
178
|
-
expect(screen.getByTestId("newsletter-success-headline")).toHaveTextContent("Check your inbox"),
|
|
179
|
-
);
|
|
180
|
-
expect(mockSubmitStep).toHaveBeenCalledWith("newsletter", {
|
|
181
|
-
stepKey: "subscribe",
|
|
182
|
-
values: { email: "a@b.co", "terms.newsletter": true },
|
|
183
|
-
locale: "en",
|
|
184
|
-
});
|
|
185
|
-
expect(leads.subscribe).not.toHaveBeenCalled();
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it("with the hub unreadable, the seeded config renders", async () => {
|
|
189
|
-
mockFlowsGet.mockRejectedValue(new Error("hub down"));
|
|
190
|
-
|
|
191
|
-
await renderWith(STARTER_SECTIONS);
|
|
192
|
-
|
|
193
|
-
expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Get the newsletter");
|
|
194
|
-
expect(screen.getByTestId("newsletter-form")).toBeInTheDocument();
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
it("with capture off, ContactFallback with the _site.mdx email renders and no newsletter form", async () => {
|
|
198
|
-
mockCaptureStatus.mockResolvedValue(status(false));
|
|
199
|
-
|
|
200
|
-
await renderWith(STARTER_SECTIONS);
|
|
201
|
-
|
|
202
|
-
expect(screen.queryByTestId("newsletter-form")).toBeNull();
|
|
203
|
-
expect(document.querySelector("a[href='mailto:hi@x.co']")).not.toBeNull();
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it("an authored newsletter section never renders beside the slot (one signup form)", async () => {
|
|
207
|
-
await renderWith([...STARTER_SECTIONS, LEGACY_SECTIONS[1]]);
|
|
208
|
-
|
|
209
|
-
expect(screen.getAllByTestId("newsletter-form")).toHaveLength(1);
|
|
210
|
-
expect(document.querySelector("form[action='/v1/leads/subscribe']")).toBeNull();
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe("NewsletterPage — a page with no contact-form section keeps its composition (#6730 D9)", () => {
|
|
215
|
-
it("newsletter:true + its own newsletter section → that section renders, no second form", async () => {
|
|
216
|
-
await renderWith(LEGACY_SECTIONS);
|
|
217
|
-
|
|
218
|
-
expect(screen.getAllByTestId("newsletter-form")).toHaveLength(1);
|
|
219
|
-
expect(document.querySelector("a[href='#signup']")).not.toBeNull();
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it("newsletter:false → the signup section and the hero CTA to it are dropped", async () => {
|
|
223
|
-
mockCaptureStatus.mockResolvedValue(status(false));
|
|
224
|
-
|
|
225
|
-
await renderWith(LEGACY_SECTIONS);
|
|
226
|
-
|
|
227
|
-
expect(screen.queryByTestId("newsletter-form")).toBeNull();
|
|
228
|
-
expect(document.querySelector("a[href='#signup']")).toBeNull();
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
it("newsletter:true + no signup section → the magnet's form is appended", async () => {
|
|
232
|
-
await renderWith([{ id: "faq", type: "faq", data: { items: [] } }]);
|
|
233
|
-
|
|
234
|
-
expect(screen.getAllByTestId("newsletter-form")).toHaveLength(1);
|
|
235
|
-
});
|
|
236
|
-
});
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
// Newsletter page (#6658 D5) — a NewsletterSignup at /newsletter. A
|
|
2
|
-
// module-less surface a template enables by naming it in its roster; with no
|
|
3
|
-
// content the route 404s. Mirrors for/page.tsx: a sections-composed
|
|
4
|
-
// page renders its sections, a prose-only page its MDX body.
|
|
5
|
-
//
|
|
6
|
-
// The newsletter magnet is the only source (#8847 D11): the page reads the
|
|
7
|
-
// workspace's `newsletter` magnet (`flows.get("newsletter")`, shared for 15
|
|
8
|
-
// seconds per instance like /contact's read), else the seeded
|
|
9
|
-
// `newsletterFlowConfig` when the hub cannot be read. Its step title is the
|
|
10
|
-
// page's H1 and `<title>`, its body the line under it (`framedSources`), and
|
|
11
|
-
// the standard `NewsletterFormInline` — label, consent, help line, button and
|
|
12
|
-
// ending all the magnet's — goes into the page's first `contact-form`
|
|
13
|
-
// section, bound to `subscribeNewsletterAction`. Rendered on every request.
|
|
14
|
-
//
|
|
15
|
-
// A signup only when there is somewhere to keep it (#6730 D9): when the API
|
|
16
|
-
// does not accept a subscription (`GET /v1/leads/capture` — a database is set
|
|
17
|
-
// up), the slot holds `ContactFallback` with the site's contact email.
|
|
18
|
-
//
|
|
19
|
-
// An authored `newsletter` section never renders beside the slot. A page with
|
|
20
|
-
// no `contact-form` section keeps the composition it had before
|
|
21
|
-
// #8847: a content `newsletter` section renders as authored when accepting
|
|
22
|
-
// (its own form posts to `/v1/leads/subscribe`), a page with no such section
|
|
23
|
-
// gets the signup appended, and when not accepting every `newsletter` section
|
|
24
|
-
// is dropped before render, with any leading-hero CTA that pointed at a
|
|
25
|
-
// dropped section's anchor.
|
|
26
|
-
import type {
|
|
27
|
-
getMdxSource as defaultGetMdxSource,
|
|
28
|
-
getPageSections as defaultGetPageSections,
|
|
29
|
-
} from "@working-theory/page-renderer";
|
|
30
|
-
import {
|
|
31
|
-
getMdxSource as loadMdxSource,
|
|
32
|
-
getPageSections as loadPageSections,
|
|
33
|
-
renderPage,
|
|
34
|
-
renderPageMetadata,
|
|
35
|
-
} from "@working-theory/page-renderer";
|
|
36
|
-
import { ContactFallback } from "@working-theory/ui";
|
|
37
|
-
import { NEWSLETTER_FLOW_SLUG, newsletterFlowConfig } from "@working-theory/validation";
|
|
38
|
-
import type { Metadata } from "next";
|
|
39
|
-
import { getTranslations } from "next-intl/server";
|
|
40
|
-
import type { ReactElement } from "react";
|
|
41
|
-
|
|
42
|
-
import {
|
|
43
|
-
framedSources,
|
|
44
|
-
inPageView,
|
|
45
|
-
type InPageView,
|
|
46
|
-
newsletterSignup,
|
|
47
|
-
type NewsletterFormView,
|
|
48
|
-
readCaptureStatus,
|
|
49
|
-
readServedMagnet,
|
|
50
|
-
} from "../../../lib/in-page-magnet";
|
|
51
|
-
import { readSiteContactEmail } from "../contact/site-contact-email";
|
|
52
|
-
|
|
53
|
-
// #8847 D11 — rendered on every request; the magnet read behind it is shared for 15 seconds.
|
|
54
|
-
export const dynamic = "force-dynamic";
|
|
55
|
-
|
|
56
|
-
interface Props {
|
|
57
|
-
params: Promise<{ locale: string }>;
|
|
58
|
-
getMdxSource?: typeof defaultGetMdxSource;
|
|
59
|
-
getPageSections?: typeof defaultGetPageSections;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
type Section = Awaited<ReturnType<typeof defaultGetPageSections>>[number];
|
|
63
|
-
type NewsletterView = InPageView & { form: NewsletterFormView };
|
|
64
|
-
|
|
65
|
-
/** The served newsletter magnet's view when it maps, else the seeded config's. */
|
|
66
|
-
async function newsletterView(locale: string): Promise<NewsletterView> {
|
|
67
|
-
const magnet = await readServedMagnet(NEWSLETTER_FLOW_SLUG);
|
|
68
|
-
const view =
|
|
69
|
-
(magnet ? inPageView(magnet, locale, "newsletter") : null) ??
|
|
70
|
-
// The seeded config always maps: one step, its email and consent fields.
|
|
71
|
-
inPageView(newsletterFlowConfig, locale, "newsletter")!;
|
|
72
|
-
return view as NewsletterView;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Drop every `newsletter` section, and any leading-hero CTA whose `href` is
|
|
77
|
-
* the `#<id>` anchor of a section that was dropped.
|
|
78
|
-
*/
|
|
79
|
-
function withoutSignup(sections: Section[]): Section[] {
|
|
80
|
-
const dropped = new Set(
|
|
81
|
-
sections.filter((s) => s.type === "newsletter").map((s) => `#${s.id}`),
|
|
82
|
-
);
|
|
83
|
-
if (dropped.size === 0) return sections;
|
|
84
|
-
return sections
|
|
85
|
-
.filter((s) => s.type !== "newsletter")
|
|
86
|
-
.map((s, i) => {
|
|
87
|
-
if (i !== 0 || s.type !== "hero") return s;
|
|
88
|
-
const data = { ...s.data };
|
|
89
|
-
if (data.primaryCta && dropped.has(data.primaryCta.href)) delete data.primaryCta;
|
|
90
|
-
if (data.secondaryCta && dropped.has(data.secondaryCta.href)) delete data.secondaryCta;
|
|
91
|
-
return { ...s, data };
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export async function generateMetadata({
|
|
96
|
-
params,
|
|
97
|
-
getMdxSource,
|
|
98
|
-
getPageSections,
|
|
99
|
-
}: Props): Promise<Metadata> {
|
|
100
|
-
const { locale } = await params;
|
|
101
|
-
const view = await newsletterView(locale);
|
|
102
|
-
// #8847 D11 — the `<title>` is the magnet's step title, like the H1.
|
|
103
|
-
const framed = framedSources({
|
|
104
|
-
getMdxSource: getMdxSource ?? loadMdxSource,
|
|
105
|
-
getPageSections: getPageSections ?? loadPageSections,
|
|
106
|
-
view,
|
|
107
|
-
});
|
|
108
|
-
return renderPageMetadata({
|
|
109
|
-
type: "NewsletterSignup",
|
|
110
|
-
slug: "newsletter",
|
|
111
|
-
locale,
|
|
112
|
-
getMdxSource: framed.getMdxSource,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export default async function Page({
|
|
117
|
-
params,
|
|
118
|
-
getMdxSource,
|
|
119
|
-
getPageSections,
|
|
120
|
-
}: Props): Promise<ReactElement> {
|
|
121
|
-
const { locale } = await params;
|
|
122
|
-
const [status, view] = await Promise.all([readCaptureStatus(), newsletterView(locale)]);
|
|
123
|
-
const accepting = status?.newsletter === true;
|
|
124
|
-
const framed = framedSources({
|
|
125
|
-
getMdxSource: getMdxSource ?? loadMdxSource,
|
|
126
|
-
getPageSections: getPageSections ?? loadPageSections,
|
|
127
|
-
view,
|
|
128
|
-
});
|
|
129
|
-
const source = await framed.getMdxSource("NewsletterSignup", "newsletter", locale);
|
|
130
|
-
const declared = source ? await framed.getPageSections(source.frontmatter) : [];
|
|
131
|
-
const composed = declared.length > 0;
|
|
132
|
-
const slot = declared.find((s) => s.type === "contact-form")?.id;
|
|
133
|
-
const hasSignupSection = declared.some((s) => s.type === "newsletter");
|
|
134
|
-
const contactEmail = readSiteContactEmail();
|
|
135
|
-
|
|
136
|
-
let surface: ReactElement;
|
|
137
|
-
if (accepting) {
|
|
138
|
-
surface = newsletterSignup(view, {
|
|
139
|
-
locale,
|
|
140
|
-
className: "mx-auto",
|
|
141
|
-
...(contactEmail !== undefined && { fallbackEmail: contactEmail }),
|
|
142
|
-
});
|
|
143
|
-
} else {
|
|
144
|
-
const tc = await getTranslations({ locale, namespace: "contact" });
|
|
145
|
-
surface = (
|
|
146
|
-
<ContactFallback
|
|
147
|
-
email={contactEmail}
|
|
148
|
-
text={{
|
|
149
|
-
heading: tc("unavailableHeading"),
|
|
150
|
-
body: tc("unavailableBody", { email: "{email}" }),
|
|
151
|
-
noEmail: tc("unavailableNoEmail"),
|
|
152
|
-
}}
|
|
153
|
-
/>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const rendered = await renderPage({
|
|
158
|
-
type: "NewsletterSignup",
|
|
159
|
-
slug: "newsletter",
|
|
160
|
-
locale,
|
|
161
|
-
...(composed ? {} : { bodyMode: "mdx-body" as const }),
|
|
162
|
-
getMdxSource: framed.getMdxSource,
|
|
163
|
-
// With a slot the magnet's form is the page's one signup, so an authored
|
|
164
|
-
// `newsletter` section (posting around the magnet) never renders beside it.
|
|
165
|
-
getPageSections:
|
|
166
|
-
accepting && slot === undefined
|
|
167
|
-
? framed.getPageSections
|
|
168
|
-
: async (frontmatter: unknown) => withoutSignup(await framed.getPageSections(frontmatter)),
|
|
169
|
-
...(slot !== undefined && { sectionSlots: { [slot]: surface } }),
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
if (slot !== undefined || !accepting || hasSignupSection || source === null) return rendered;
|
|
173
|
-
return (
|
|
174
|
-
<>
|
|
175
|
-
{rendered}
|
|
176
|
-
{surface}
|
|
177
|
-
</>
|
|
178
|
-
);
|
|
179
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
// i18n S2 — Home page under [locale] segment (#949)
|
|
2
|
-
//
|
|
3
|
-
// Migrated from app/page.tsx to app/[locale]/page.tsx.
|
|
4
|
-
// Reads the HomePage MDX frontmatter, renders sections via SectionRenderer,
|
|
5
|
-
// and emits a JSON-LD <script> for crawlers.
|
|
6
|
-
|
|
7
|
-
import type {
|
|
8
|
-
getMdxSource as defaultGetMdxSource,
|
|
9
|
-
getPageSections as defaultGetPageSections} from "@working-theory/page-renderer";
|
|
10
|
-
import {
|
|
11
|
-
renderPage,
|
|
12
|
-
renderPageMetadata
|
|
13
|
-
} from "@working-theory/page-renderer";
|
|
14
|
-
import type { HeaderStyle } from "@working-theory/site-config/schema";
|
|
15
|
-
import { localeHref } from "@working-theory/ui";
|
|
16
|
-
import type { Metadata } from "next";
|
|
17
|
-
import { redirect } from "next/navigation";
|
|
18
|
-
import type { ReactElement } from "react";
|
|
19
|
-
|
|
20
|
-
import { MARKETING_PAGES } from "../../lib/modules.generated";
|
|
21
|
-
import { resolveHomeChrome } from "../../lib/page-chrome";
|
|
22
|
-
import { siteChrome, type SiteChrome } from "../../lib/site-chrome";
|
|
23
|
-
import { siteLogomarkAsset, siteWordmarkAsset } from "../../lib/site-logo";
|
|
24
|
-
|
|
25
|
-
/** The ground sequence `renderPage` cycles over a deck home's slides (#7719). */
|
|
26
|
-
type DeckGrounds = NonNullable<Parameters<typeof renderPage>[0]["deckGrounds"]>;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The generated `siteChrome`, read through a widened type: its interface
|
|
30
|
-
* carries `deckGrounds` only when the site's design sets one (#7719 D3), so
|
|
31
|
-
* this compiles against both shapes of the generated file.
|
|
32
|
-
*/
|
|
33
|
-
const chrome: SiteChrome & {
|
|
34
|
-
deckGrounds?: DeckGrounds;
|
|
35
|
-
deckPresentation?: true;
|
|
36
|
-
deckAnchors?: "bare";
|
|
37
|
-
} = siteChrome;
|
|
38
|
-
|
|
39
|
-
interface Props {
|
|
40
|
-
params: Promise<{ locale: string }>;
|
|
41
|
-
/**
|
|
42
|
-
* Overrides for testing — inject stubs to avoid mocking internal modules.
|
|
43
|
-
* Production code leaves these undefined and uses the real implementations.
|
|
44
|
-
*/
|
|
45
|
-
getMdxSource?: typeof defaultGetMdxSource;
|
|
46
|
-
getPageSections?: typeof defaultGetPageSections;
|
|
47
|
-
/**
|
|
48
|
-
* The home's layout; defaults to the resolved one (#10049 D6) — the home's
|
|
49
|
-
* own `layout:`, else `_site.mdx`'s, else the generated `siteChrome`'s.
|
|
50
|
-
*/
|
|
51
|
-
home?: SiteChrome["home"];
|
|
52
|
-
/**
|
|
53
|
-
* The home's header style (#10049 D6); defaults to the resolved one. When
|
|
54
|
-
* `home` is passed and this is not, it is `bare` for a deck, else `full`.
|
|
55
|
-
*/
|
|
56
|
-
homeHeader?: HeaderStyle;
|
|
57
|
-
/** The design's `layout.deckGrounds`; defaults to the generated `siteChrome`'s. */
|
|
58
|
-
deckGrounds?: DeckGrounds;
|
|
59
|
-
/** The design's `layout.deckPresentation` (#7740); defaults to the generated `siteChrome`'s. */
|
|
60
|
-
deckPresentation?: boolean;
|
|
61
|
-
/** The design's `layout.deckAnchors` (#8773): `bare` names the slides `#<id>`; defaults to the generated `siteChrome`'s. */
|
|
62
|
-
deckAnchors?: "bare";
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export async function generateMetadata({
|
|
66
|
-
params,
|
|
67
|
-
}: Pick<Props, "params">): Promise<Metadata> {
|
|
68
|
-
const { locale } = await params;
|
|
69
|
-
// #10040 decision 1 — a site without the marketing module has no home page.
|
|
70
|
-
if (!MARKETING_PAGES) return {};
|
|
71
|
-
return renderPageMetadata({ type: "HomePage", slug: "home", locale });
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* The home's layout and header (#10049 D6). A caller that passes `home`
|
|
76
|
-
* keeps the pre-#10049 behaviour: a deck's header is bare.
|
|
77
|
-
*/
|
|
78
|
-
async function resolveHome(
|
|
79
|
-
locale: string,
|
|
80
|
-
home: SiteChrome["home"] | undefined,
|
|
81
|
-
homeHeader: HeaderStyle | undefined,
|
|
82
|
-
): Promise<{ home: SiteChrome["home"]; homeHeader: HeaderStyle }> {
|
|
83
|
-
if (home !== undefined) {
|
|
84
|
-
return { home, homeHeader: homeHeader ?? (home === "deck" ? "bare" : "full") };
|
|
85
|
-
}
|
|
86
|
-
const resolved = await resolveHomeChrome(locale, chrome);
|
|
87
|
-
return { home: resolved.layout, homeHeader: homeHeader ?? resolved.chrome.header };
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export default async function Page({
|
|
91
|
-
params,
|
|
92
|
-
getMdxSource,
|
|
93
|
-
getPageSections,
|
|
94
|
-
home: homeProp,
|
|
95
|
-
homeHeader: homeHeaderProp,
|
|
96
|
-
deckGrounds = chrome.deckGrounds,
|
|
97
|
-
deckPresentation = chrome.deckPresentation,
|
|
98
|
-
deckAnchors = chrome.deckAnchors,
|
|
99
|
-
}: Props): Promise<ReactElement> {
|
|
100
|
-
const { locale } = await params;
|
|
101
|
-
// #10040 decision 1 — on a site without the marketing module (a hub) `/`
|
|
102
|
-
// goes to the account area; signed out, the authed gate sends it on to
|
|
103
|
-
// sign-in. Read before any content, so a hub never renders a missing
|
|
104
|
-
// HomePage seed.
|
|
105
|
-
if (!MARKETING_PAGES) redirect(localeHref(locale, "/account"));
|
|
106
|
-
const { home, homeHeader } = await resolveHome(locale, homeProp, homeHeaderProp);
|
|
107
|
-
return renderPage({
|
|
108
|
-
type: "HomePage",
|
|
109
|
-
slug: "home",
|
|
110
|
-
locale,
|
|
111
|
-
translationsNamespace: "home",
|
|
112
|
-
populatedDescriptionTestId: "home-description",
|
|
113
|
-
emptyStateTestId: "home-description",
|
|
114
|
-
...(getMdxSource !== undefined && { getMdxSource }),
|
|
115
|
-
...(getPageSections !== undefined && { getPageSections }),
|
|
116
|
-
// #7733 — the deck home's header is bare on slide 1 (#5697), so its
|
|
117
|
-
// landing carries the brand: a centred leading hero renders as bondcap's
|
|
118
|
-
// landing with the site's wordmark in the headline's place; any other
|
|
119
|
-
// leading hero keeps its composition and takes the logomark (#7711).
|
|
120
|
-
// Content that authors its own lockup keeps it.
|
|
121
|
-
// #10049 D5 — under a full header the home keeps its bar, so no landing.
|
|
122
|
-
...(home === "deck" &&
|
|
123
|
-
homeHeader !== "full" && {
|
|
124
|
-
deckLanding: { wordmark: siteWordmarkAsset(), logomark: siteLogomarkAsset() },
|
|
125
|
-
}),
|
|
126
|
-
// #7719 — a deck home cycles its design's ground sequence, slide by
|
|
127
|
-
// slide, onto every slide that authors no surface of its own.
|
|
128
|
-
...(home === "deck" && deckGrounds !== undefined && { deckGrounds }),
|
|
129
|
-
// #10049 — a deck home under a full header passes no landing, so on a
|
|
130
|
-
// design with no grounds it would carry none of the deck inputs and
|
|
131
|
-
// renderPage would treat it as a plain page, emitting a section-anchor
|
|
132
|
-
// span before each section — each one a full-height snap slide. An empty
|
|
133
|
-
// ground sequence (a documented no-op, `applyDeckGrounds`) keeps it a deck.
|
|
134
|
-
...(home === "deck" &&
|
|
135
|
-
homeHeader === "full" &&
|
|
136
|
-
deckGrounds === undefined && { deckGrounds: [] }),
|
|
137
|
-
// #7740 — a deck home under the presentation dial: every slide with an
|
|
138
|
-
// alignment field centred, card grids one column on phones, and slide
|
|
139
|
-
// anchors clear of the page's JSON-LD @id fragments.
|
|
140
|
-
...(home === "deck" && deckPresentation === true && { deckPresentation: true }),
|
|
141
|
-
// #8773 — and, when the design chooses it, names those slides `#<id>`
|
|
142
|
-
// (the `slide-` name kept only where the bare id would collide).
|
|
143
|
-
...(home === "deck" &&
|
|
144
|
-
deckPresentation === true &&
|
|
145
|
-
deckAnchors === "bare" && { deckAnchorStyle: "bare" as const }),
|
|
146
|
-
});
|
|
147
|
-
}
|