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.
- package/component-catalog.json +1 -1
- package/component-catalog.md +1 -1
- 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 +19 -2
- 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 +42 -25
- package/templates/apps/web/app/api/revalidate/__tests__/route.test.ts +56 -1
- package/templates/apps/web/app/api/revalidate/route.ts +45 -4
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +53 -0
- package/templates/apps/web/app/llms.txt/route.ts +5 -2
- 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__/hub-site-config.test.ts +239 -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__/profile-back-link.test.ts +58 -0
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +163 -20
- package/templates/apps/web/lib/__tests__/site-brand.test.ts +77 -0
- package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +64 -0
- package/templates/apps/web/lib/__tests__/site-identity-feature-list.test.ts +115 -3
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
- package/templates/apps/web/lib/hub-site-config.ts +151 -0
- 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/lib/profile-back-link.ts +49 -12
- package/templates/apps/web/lib/served-pages.ts +144 -39
- package/templates/apps/web/lib/site-brand.tsx +66 -0
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +25 -5
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +21 -5
- package/templates/apps/web/lib/site-header.ts +1 -1
- package/templates/apps/web/lib/site-identity.ts +38 -2
- package/templates/apps/web/messages/en.json +3 -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
|
@@ -8,20 +8,28 @@
|
|
|
8
8
|
* (`app/sitemap.xml/route.ts`: `listPages` per type, `listedPath` over
|
|
9
9
|
* the site's listing, docs rows and `ThankYouPage` left out). Title =
|
|
10
10
|
* the page's frontmatter `title`.
|
|
11
|
-
* 2. Every
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* route
|
|
11
|
+
* 2. Every page route the app builds (#11438) — its page files under
|
|
12
|
+
* `app/`, and Next's app-path routes manifest where those files are not
|
|
13
|
+
* deployed — whatever module or site file put it there. No title. A
|
|
14
|
+
* route with no dynamic segment is a served path in itself; one with a
|
|
15
|
+
* dynamic segment (`[slug]`) serves the candidates the caller asks about
|
|
16
|
+
* that it matches, so `/flows/<slug>` counts under its start page. An
|
|
17
|
+
* optional catch-all serves its own index only; a required catch-all,
|
|
18
|
+
* and a route of dynamic segments alone (the content catch-all), serve
|
|
19
|
+
* nothing.
|
|
20
|
+
* A route with seed content (a `ROUTES` row with a `contentPath`) counts only
|
|
21
|
+
* through source 1, so a scaffold that dropped that surface's content never
|
|
22
|
+
* gets a link to a missing page. The layout adds the nav and footer paths
|
|
23
|
+
* itself (every nav entry is a route the site carries — `lib/nav-config.ts`).
|
|
19
24
|
*
|
|
20
25
|
* Shared per server instance for 60 seconds per locale, and fail-safe: any
|
|
21
26
|
* read that throws leaves that source out, so the arrow degrades toward the
|
|
22
27
|
* home, never to an error.
|
|
23
28
|
*/
|
|
24
29
|
|
|
30
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
31
|
+
import { join } from "node:path";
|
|
32
|
+
|
|
25
33
|
import { SCHEMA_ORG_TYPES } from "@working-theory/content-adapters";
|
|
26
34
|
import type { SchemaOrgType } from "@working-theory/content-adapters";
|
|
27
35
|
import { getContentAdapter, listedPath } from "@working-theory/page-renderer";
|
|
@@ -30,36 +38,120 @@ import { ROUTES } from "@working-theory/templates/routes";
|
|
|
30
38
|
import { pagePathFor } from "../src/lib/routes";
|
|
31
39
|
|
|
32
40
|
import { isDocsType } from "./docs-index";
|
|
33
|
-
import {
|
|
34
|
-
DOCS_BLOG_PAGES,
|
|
35
|
-
MARKETING_PAGES,
|
|
36
|
-
SCHEDULING_PAGES,
|
|
37
|
-
} from "./modules.generated";
|
|
38
41
|
import { SITE_LISTING } from "./site-listing";
|
|
39
42
|
|
|
40
43
|
const TTL_MS = 60_000;
|
|
41
44
|
|
|
42
|
-
/** The
|
|
43
|
-
const
|
|
44
|
-
marketing: MARKETING_PAGES,
|
|
45
|
-
scheduling: SCHEDULING_PAGES,
|
|
46
|
-
"docs-blog": DOCS_BLOG_PAGES,
|
|
47
|
-
};
|
|
45
|
+
/** The app's locale segment, under which every site page route sits. */
|
|
46
|
+
const LOCALE_SEGMENT = "[locale]";
|
|
48
47
|
|
|
49
|
-
const
|
|
50
|
-
string,
|
|
51
|
-
{ at: number; pages: Promise<ReadonlyMap<string, string>> }
|
|
52
|
-
>();
|
|
48
|
+
const PAGE_FILE = /^page\.(?:tsx|ts|jsx|js|mdx)$/;
|
|
53
49
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
interface ServedSet {
|
|
51
|
+
/** Bare path → title for every served path. */
|
|
52
|
+
pages: ReadonlyMap<string, string>;
|
|
53
|
+
/** The built routes with a dynamic segment, as segments. */
|
|
54
|
+
dynamic: readonly (readonly string[])[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const cache = new Map<string, { at: number; served: Promise<ServedSet> }>();
|
|
58
|
+
|
|
59
|
+
function isDynamic(segment: string): boolean {
|
|
60
|
+
return segment.startsWith("[") || segment.startsWith(":");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** A route's shape: its segments, every dynamic one as `*`, whatever its name. */
|
|
64
|
+
function shape(segments: readonly string[]): string {
|
|
65
|
+
return segments.map((segment) => (isDynamic(segment) ? "*" : segment)).join("/");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The shapes of the routes whose pages render seed content. */
|
|
69
|
+
const CONTENT_SHAPES = new Set(
|
|
70
|
+
ROUTES.filter((row) => row.contentPath !== undefined).map((row) =>
|
|
71
|
+
shape(row.route.split("/").filter(Boolean)),
|
|
72
|
+
),
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
/** Every page route under `dir`, from its page files, route groups dropped. */
|
|
76
|
+
function pageFileRoutes(dir: string, route = ""): string[] {
|
|
77
|
+
const routes: string[] = [];
|
|
78
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
79
|
+
if (entry.isFile() && PAGE_FILE.test(entry.name)) routes.push(route);
|
|
80
|
+
// `_private` folders and `@slot`s are not URL segments; a `(group)` adds none.
|
|
81
|
+
if (!entry.isDirectory() || /^[_@]/.test(entry.name)) continue;
|
|
82
|
+
const segment = /^\(.*\)$/.test(entry.name) ? "" : `/${entry.name}`;
|
|
83
|
+
routes.push(...pageFileRoutes(join(dir, entry.name), route + segment));
|
|
84
|
+
}
|
|
85
|
+
return routes;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Every page route in Next's app-path routes manifest (route handlers left out). */
|
|
89
|
+
function manifestRoutes(root: string): string[] {
|
|
90
|
+
const distDir = process.env.__NEXT_RELATIVE_DIST_DIR || ".next";
|
|
91
|
+
const manifest: unknown = JSON.parse(
|
|
92
|
+
readFileSync(join(root, distDir, "app-path-routes-manifest.json"), "utf8"),
|
|
93
|
+
);
|
|
94
|
+
if (typeof manifest !== "object" || manifest === null) return [];
|
|
95
|
+
return Object.entries(manifest)
|
|
96
|
+
.filter(([entry, route]) => entry.endsWith("/page") && typeof route === "string")
|
|
97
|
+
.map(([, route]) => route as string);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function readSafely(read: () => string[]): string[] {
|
|
101
|
+
try {
|
|
102
|
+
return read();
|
|
103
|
+
} catch {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The page routes the app builds, as locale-less segments: an optional
|
|
110
|
+
* catch-all's index kept, a required catch-all, a route of dynamic segments
|
|
111
|
+
* alone, the home and every seed-content route left out.
|
|
112
|
+
*/
|
|
113
|
+
function builtRoutes(): string[][] {
|
|
114
|
+
const root = process.cwd();
|
|
115
|
+
const routes = new Set([
|
|
116
|
+
...readSafely(() => pageFileRoutes(join(root, "app"))),
|
|
117
|
+
...readSafely(() => manifestRoutes(root)),
|
|
118
|
+
]);
|
|
119
|
+
if (routes.size === 0) {
|
|
120
|
+
// Neither the page files nor the manifest could be read: every code
|
|
121
|
+
// route's arrow falls through to home, so say so once per read.
|
|
122
|
+
console.warn("[served-pages] no page route of the app could be read; the back arrow sees content pages only");
|
|
123
|
+
}
|
|
124
|
+
const built: string[][] = [];
|
|
125
|
+
for (const route of routes) {
|
|
126
|
+
const segments = route.split("/").filter(Boolean);
|
|
127
|
+
// A `_private` segment is never a URL; the walk skips such folders, and
|
|
128
|
+
// the manifest's own entries (`/_not-found`) start with one too.
|
|
129
|
+
if (segments.some((segment) => segment.startsWith("_"))) continue;
|
|
130
|
+
if (segments[0] === LOCALE_SEGMENT) segments.shift();
|
|
131
|
+
if (segments[segments.length - 1]?.startsWith("[[...")) segments.pop();
|
|
132
|
+
if (segments.some((segment) => segment.startsWith("[..."))) continue;
|
|
133
|
+
if (segments.every(isDynamic)) continue;
|
|
134
|
+
if (CONTENT_SHAPES.has(shape(segments))) continue;
|
|
135
|
+
built.push(segments);
|
|
136
|
+
}
|
|
137
|
+
return built;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function matches(route: readonly string[], path: string): boolean {
|
|
141
|
+
const segments = path.split("/").filter(Boolean);
|
|
142
|
+
return (
|
|
143
|
+
segments.length === route.length &&
|
|
144
|
+
route.every((segment, i) => isDynamic(segment) || segment === segments[i])
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function readServedSet(locale: string): Promise<ServedSet> {
|
|
57
149
|
const pages = new Map<string, string>();
|
|
150
|
+
const dynamic: string[][] = [];
|
|
58
151
|
|
|
59
|
-
for (const
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
pages.set(row.route, "");
|
|
152
|
+
for (const route of builtRoutes()) {
|
|
153
|
+
if (route.some(isDynamic)) dynamic.push(route);
|
|
154
|
+
else pages.set(`/${route.join("/")}`, "");
|
|
63
155
|
}
|
|
64
156
|
|
|
65
157
|
try {
|
|
@@ -76,20 +168,33 @@ async function readServedPages(
|
|
|
76
168
|
}
|
|
77
169
|
}
|
|
78
170
|
} catch {
|
|
79
|
-
// No adapter: the
|
|
171
|
+
// No adapter: the built page routes alone.
|
|
80
172
|
}
|
|
81
173
|
|
|
82
|
-
return pages;
|
|
174
|
+
return { pages, dynamic };
|
|
83
175
|
}
|
|
84
176
|
|
|
85
|
-
/**
|
|
86
|
-
|
|
177
|
+
/**
|
|
178
|
+
* Bare path → title ("" when the page has none) for every page served in
|
|
179
|
+
* `locale`, plus each of `candidates` (bare paths — the page's ancestors,
|
|
180
|
+
* `ancestorPaths`) that a built dynamic route serves.
|
|
181
|
+
*/
|
|
182
|
+
export async function servedPages(
|
|
87
183
|
locale: string,
|
|
184
|
+
candidates: readonly string[] = [],
|
|
88
185
|
): Promise<ReadonlyMap<string, string>> {
|
|
89
186
|
const now = Date.now();
|
|
90
|
-
|
|
91
|
-
if (hit
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
187
|
+
let hit = cache.get(locale);
|
|
188
|
+
if (!hit || now - hit.at >= TTL_MS) {
|
|
189
|
+
hit = { at: now, served: readServedSet(locale) };
|
|
190
|
+
cache.set(locale, hit);
|
|
191
|
+
}
|
|
192
|
+
const { pages, dynamic } = await hit.served;
|
|
193
|
+
const matched = candidates.filter(
|
|
194
|
+
(path) => !pages.has(path) && dynamic.some((route) => matches(route, path)),
|
|
195
|
+
);
|
|
196
|
+
if (matched.length === 0) return pages;
|
|
197
|
+
const withMatched = new Map(pages);
|
|
198
|
+
for (const path of matched) withMatched.set(path, "");
|
|
199
|
+
return withMatched;
|
|
95
200
|
}
|
|
@@ -25,6 +25,13 @@
|
|
|
25
25
|
* the agent-operator editing workflow — disproportionate for reading two
|
|
26
26
|
* fields. See docs/specs/4157-scaffold-brand-defaults-spec.md § Design
|
|
27
27
|
* Decisions (D1) for the full reasoning.
|
|
28
|
+
*
|
|
29
|
+
* #11456 D4 — on a hub-connected site the hub holds the brand: the async
|
|
30
|
+
* `resolveSiteBrand()` answers the hub identity's name, description and legal
|
|
31
|
+
* name, and the seo row's indexing switch, read per request through
|
|
32
|
+
* `lib/hub-site-config.ts`. The constants below are unchanged and are what it
|
|
33
|
+
* answers when there is no hub identity row, a failed read, or no hub
|
|
34
|
+
* connection.
|
|
28
35
|
*/
|
|
29
36
|
|
|
30
37
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -32,6 +39,8 @@ import { join } from "node:path";
|
|
|
32
39
|
|
|
33
40
|
import { parse as parseYaml } from "yaml";
|
|
34
41
|
|
|
42
|
+
import { readHubSite, type HubSite } from "./hub-site-config";
|
|
43
|
+
|
|
35
44
|
/** Neutral, non-vendor fallback — see module doc comment point 3. */
|
|
36
45
|
export const FALLBACK_SITE_NAME = "My Site";
|
|
37
46
|
/** Neutral, non-vendor fallback — see module doc comment point 3. */
|
|
@@ -154,3 +163,60 @@ export const COPYRIGHT_HOLDER = siteFrontmatter?.legalName ?? SITE_NAME;
|
|
|
154
163
|
* `SITE_BASE_URL` for the routes that read only those.
|
|
155
164
|
*/
|
|
156
165
|
export const SITE_LOGOMARK: unknown = siteFrontmatter?.logomark;
|
|
166
|
+
|
|
167
|
+
/** The brand the locale layout and both llms.txt routes render (#11456 D4). */
|
|
168
|
+
export interface SiteBrand {
|
|
169
|
+
siteName: string;
|
|
170
|
+
description: string;
|
|
171
|
+
copyrightHolder: string;
|
|
172
|
+
/** False when the hub's seo row turns search indexing off (`robots.index: false`). */
|
|
173
|
+
indexable: boolean;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* A hub value as one line: every run of control, format (bidi overrides,
|
|
178
|
+
* zero-width characters), line-separator and paragraph-separator characters
|
|
179
|
+
* becomes one space (SEC-11456-5). A hub value is written by any member
|
|
180
|
+
* holding `workspace-settings`, and lands in the plain-text llms.txt heading,
|
|
181
|
+
* where a newline would add lines.
|
|
182
|
+
*/
|
|
183
|
+
function oneLine(value: string): string {
|
|
184
|
+
return value.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]+/gu, " ").trim();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* The site's brand for this request (#11456 D4). With a hub identity row, that
|
|
189
|
+
* row is the whole identity: a field the operator cleared is absent, never
|
|
190
|
+
* refilled from `_site.mdx` — `siteName` is `NEXT_PUBLIC_SITE_NAME`, else the
|
|
191
|
+
* hub `name`; `description` the hub's, else the seo row's, else the neutral
|
|
192
|
+
* fallback; `copyrightHolder` the hub `legalName`, else the hub `siteName`.
|
|
193
|
+
* Otherwise the module's constants, exactly. `indexable` reads the seo row
|
|
194
|
+
* whether or not an identity row exists, and fails open. Never rejects.
|
|
195
|
+
*/
|
|
196
|
+
export async function resolveSiteBrand(): Promise<SiteBrand> {
|
|
197
|
+
return brandFrom(await readHubSite());
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** `resolveSiteBrand`'s rule over one hub read, so a caller holding the read derives the same brand. */
|
|
201
|
+
export function brandFrom(hub: HubSite | undefined): SiteBrand {
|
|
202
|
+
const indexable = hub?.seo?.robots?.index !== false;
|
|
203
|
+
const identity = hub?.identity;
|
|
204
|
+
if (!identity) {
|
|
205
|
+
return {
|
|
206
|
+
siteName: SITE_NAME,
|
|
207
|
+
description: SITE_DESCRIPTION,
|
|
208
|
+
copyrightHolder: COPYRIGHT_HOLDER,
|
|
209
|
+
indexable,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
const siteName =
|
|
213
|
+
oneLine(process.env.NEXT_PUBLIC_SITE_NAME ?? identity.name) || FALLBACK_SITE_NAME;
|
|
214
|
+
return {
|
|
215
|
+
siteName,
|
|
216
|
+
description:
|
|
217
|
+
oneLine(identity.description ?? hub.seo?.description ?? "") ||
|
|
218
|
+
FALLBACK_SITE_DESCRIPTION,
|
|
219
|
+
copyrightHolder: oneLine(identity.legalName ?? "") || siteName,
|
|
220
|
+
indexable,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
@@ -13,15 +13,26 @@
|
|
|
13
13
|
* the client-safe `/schema` entry. Any failure (no file, no frontmatter, an
|
|
14
14
|
* invalid address) is `undefined`: the fallback then says the site has
|
|
15
15
|
* published no contact details, which is true.
|
|
16
|
+
*
|
|
17
|
+
* #11456 D4 — on a hub-connected site that holds a hub identity row, the
|
|
18
|
+
* row's `email` (when valid) comes first, else the file's top-level
|
|
19
|
+
* `contactEmail` (not an identity field, so it stays the fallback). It reads
|
|
20
|
+
* the value `readHubSite` last resolved on this instance (`heldHubSite()`),
|
|
21
|
+
* because the seam is synchronous: the file value on a cold instance's first
|
|
22
|
+
* render.
|
|
16
23
|
*/
|
|
17
24
|
|
|
18
25
|
import { readFileSync } from "node:fs";
|
|
19
26
|
import { join } from "node:path";
|
|
20
27
|
|
|
21
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
SiteConfigSchema,
|
|
30
|
+
type SiteIdentity,
|
|
31
|
+
} from "@working-theory/site-config/schema";
|
|
22
32
|
import { parse as parseYaml } from "yaml";
|
|
23
33
|
|
|
24
|
-
import {
|
|
34
|
+
import { heldHubSite } from "./hub-site-config";
|
|
35
|
+
import { resolveContentRoot } from "./site-brand";
|
|
25
36
|
|
|
26
37
|
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---/;
|
|
27
38
|
|
|
@@ -32,23 +43,32 @@ function validEmail(value: unknown): string | undefined {
|
|
|
32
43
|
return parsed.success ? parsed.data : undefined;
|
|
33
44
|
}
|
|
34
45
|
|
|
46
|
+
/** The hub identity's `email`, when the identity kind carries one. */
|
|
47
|
+
function hubIdentityEmail(identity: SiteIdentity): string | undefined {
|
|
48
|
+
return "email" in identity ? validEmail(identity.email) : undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
35
51
|
export function readSiteContactEmail(): string | undefined {
|
|
52
|
+
const hubIdentity = heldHubSite()?.identity;
|
|
53
|
+
// With a hub identity row, every file failure still answers its email.
|
|
54
|
+
const hubEmail = hubIdentity ? hubIdentityEmail(hubIdentity) : undefined;
|
|
36
55
|
try {
|
|
37
56
|
const raw = readFileSync(join(resolveContentRoot(), "_site.mdx"), "utf8");
|
|
38
57
|
const match = FRONTMATTER_RE.exec(raw);
|
|
39
|
-
if (!match) return
|
|
58
|
+
if (!match) return hubEmail;
|
|
40
59
|
const fm: unknown = parseYaml(match[1] ?? "");
|
|
41
|
-
if (!fm || typeof fm !== "object") return
|
|
60
|
+
if (!fm || typeof fm !== "object") return hubEmail;
|
|
42
61
|
|
|
43
62
|
const { contactEmail, siteIdentity } = fm as {
|
|
44
63
|
contactEmail?: unknown;
|
|
45
64
|
siteIdentity?: { kind?: unknown; email?: unknown };
|
|
46
65
|
};
|
|
66
|
+
if (hubIdentity) return hubEmail ?? validEmail(contactEmail);
|
|
47
67
|
return (
|
|
48
68
|
validEmail(contactEmail) ??
|
|
49
69
|
(siteIdentity?.kind === "LocalBusiness" ? validEmail(siteIdentity.email) : undefined)
|
|
50
70
|
);
|
|
51
71
|
} catch {
|
|
52
|
-
return
|
|
72
|
+
return hubEmail;
|
|
53
73
|
}
|
|
54
74
|
}
|
|
@@ -16,16 +16,24 @@
|
|
|
16
16
|
* or two lines. The same local `_site.mdx` frontmatter read as its sibling
|
|
17
17
|
* `site-contact-email.ts`, for the same reason (see that file's header). Any
|
|
18
18
|
* failure is `[]`.
|
|
19
|
+
*
|
|
20
|
+
* On a hub-connected site holding a hub identity row (#11456 D4), line 1
|
|
21
|
+
* comes from that row's `address` (the value `readHubSite` last resolved,
|
|
22
|
+
* which the layout awaits first) and line 2 from `readSiteContactEmail`,
|
|
23
|
+
* which reads the same row.
|
|
19
24
|
*/
|
|
20
25
|
|
|
21
26
|
import { readFileSync } from "node:fs";
|
|
22
27
|
import { join } from "node:path";
|
|
23
28
|
|
|
24
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
SiteIdentitySchema,
|
|
31
|
+
type SiteIdentity,
|
|
32
|
+
} from "@working-theory/site-config/schema";
|
|
25
33
|
import { parse as parseYaml } from "yaml";
|
|
26
34
|
|
|
27
|
-
import {
|
|
28
|
-
|
|
35
|
+
import { heldHubSite } from "./hub-site-config";
|
|
36
|
+
import { resolveContentRoot } from "./site-brand";
|
|
29
37
|
import { readSiteContactEmail } from "./site-contact-email";
|
|
30
38
|
|
|
31
39
|
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---/;
|
|
@@ -39,8 +47,13 @@ function nonEmpty(value: unknown): string | undefined {
|
|
|
39
47
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
40
48
|
}
|
|
41
49
|
|
|
42
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* The locality line of a LocalBusiness or Person identity — the held hub
|
|
52
|
+
* row's, else the file's — or `undefined`.
|
|
53
|
+
*/
|
|
43
54
|
function readLocalityLine(): string | undefined {
|
|
55
|
+
const hubIdentity = heldHubSite()?.identity;
|
|
56
|
+
if (hubIdentity) return localityOf(hubIdentity);
|
|
44
57
|
const raw = readFileSync(join(resolveContentRoot(), "_site.mdx"), "utf8");
|
|
45
58
|
const match = FRONTMATTER_RE.exec(raw);
|
|
46
59
|
if (!match) return undefined;
|
|
@@ -48,7 +61,10 @@ function readLocalityLine(): string | undefined {
|
|
|
48
61
|
if (!fm || typeof fm !== "object") return undefined;
|
|
49
62
|
const parsed = SiteIdentitySchema.safeParse((fm as { siteIdentity?: unknown }).siteIdentity);
|
|
50
63
|
if (!parsed.success) return undefined;
|
|
51
|
-
|
|
64
|
+
return localityOf(parsed.data);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function localityOf(identity: SiteIdentity): string | undefined {
|
|
52
68
|
if (identity.kind !== "LocalBusiness" && identity.kind !== "Person") return undefined;
|
|
53
69
|
const parts = [nonEmpty(identity.address?.addressLocality), nonEmpty(identity.address?.addressRegion)].filter(
|
|
54
70
|
(part): part is string => part !== undefined,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* account" link to `/account`, where Sign out lives (#11095 D6).
|
|
8
8
|
*
|
|
9
9
|
* A local frontmatter read rather than `@working-theory/site-config/server`,
|
|
10
|
-
* for the same reason as `
|
|
10
|
+
* for the same reason as `lib/site-contact-email.ts`:
|
|
11
11
|
* `architecture.yaml` keeps `node:fs` out of a tree that also carries edge
|
|
12
12
|
* routes (#1567). The value is validated against the canonical schema from
|
|
13
13
|
* the client-safe `/schema` entry.
|
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
* module, and Next.js evaluates a layout module before any page under it
|
|
16
16
|
* renders, so every `renderPage` / `pageToJsonLd` call sees the identity
|
|
17
17
|
* without a per-route prop.
|
|
18
|
+
*
|
|
19
|
+
* #11456 D4 — a hub-connected site (`hubConnected()`) also registers a
|
|
20
|
+
* reader, which `pageToJsonLd` awaits per render: the hub identity row with
|
|
21
|
+
* the file registration's `baseUrl` (never the hub `url`, so no workspace
|
|
22
|
+
* value moves an `@id`), else the module-load registration. A site that is not
|
|
23
|
+
* hub-connected registers no reader and composes exactly as before.
|
|
18
24
|
*/
|
|
19
25
|
|
|
20
26
|
import { readdirSync, readFileSync } from "node:fs";
|
|
@@ -28,13 +34,15 @@ import {
|
|
|
28
34
|
getContentAdapter,
|
|
29
35
|
setSiteFeatureListReader,
|
|
30
36
|
setSiteIdentity,
|
|
37
|
+
setSiteIdentityReader,
|
|
31
38
|
type SiteIdentityRegistration,
|
|
32
39
|
} from "@working-theory/page-renderer";
|
|
33
40
|
import { featureListFromSections } from "@working-theory/schema";
|
|
34
41
|
import { SiteIdentitySchema } from "@working-theory/site-config/schema";
|
|
35
42
|
import { parse as parseYaml } from "yaml";
|
|
36
43
|
|
|
37
|
-
import {
|
|
44
|
+
import { hubConnected, readHubSite } from "./hub-site-config";
|
|
45
|
+
import { brandFrom, resolveContentRoot, SITE_BASE_URL } from "./site-brand";
|
|
38
46
|
|
|
39
47
|
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---/;
|
|
40
48
|
|
|
@@ -184,7 +192,35 @@ export function readSiteIdentity(
|
|
|
184
192
|
return registration;
|
|
185
193
|
}
|
|
186
194
|
|
|
187
|
-
|
|
195
|
+
/**
|
|
196
|
+
* The JSON-LD registration from the hub identity row (#11456 D4), or
|
|
197
|
+
* `undefined` when there is none. `siteName` is the brand's from the same
|
|
198
|
+
* read (one line);
|
|
199
|
+
* `baseUrl` is the file registration's, else `SITE_BASE_URL`; the file's
|
|
200
|
+
* featureList is kept only when the hub identity carries a product.
|
|
201
|
+
*/
|
|
202
|
+
async function readHubSiteIdentity(
|
|
203
|
+
file: SiteIdentityRegistration | undefined,
|
|
204
|
+
): Promise<SiteIdentityRegistration | undefined> {
|
|
205
|
+
const hub = await readHubSite();
|
|
206
|
+
const identity = hub?.identity;
|
|
207
|
+
if (!identity) return undefined;
|
|
208
|
+
const registration: SiteIdentityRegistration = {
|
|
209
|
+
siteName: brandFrom(hub).siteName,
|
|
210
|
+
baseUrl: file?.baseUrl ?? SITE_BASE_URL,
|
|
211
|
+
identity,
|
|
212
|
+
};
|
|
213
|
+
if (carriesProduct(identity) && file?.featureList !== undefined) {
|
|
214
|
+
registration.featureList = file.featureList;
|
|
215
|
+
}
|
|
216
|
+
return registration;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const fileRegistration = readSiteIdentity();
|
|
220
|
+
setSiteIdentity(fileRegistration);
|
|
221
|
+
if (hubConnected()) {
|
|
222
|
+
setSiteIdentityReader(() => readHubSiteIdentity(fileRegistration));
|
|
223
|
+
}
|
|
188
224
|
|
|
189
225
|
// #10644 D3, D4 — under the database adapter the product's featureList is
|
|
190
226
|
// read through the adapter each time a page's JSON-LD is composed: an async
|