@justanarthur/payload-www 0.1.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/README.md +381 -0
- package/dist/access.d.ts +11 -0
- package/dist/access.js +34 -0
- package/dist/blocks.d.ts +24 -0
- package/dist/blocks.js +75 -0
- package/dist/collections.d.ts +200 -0
- package/dist/collections.js +625 -0
- package/dist/components.d.ts +6 -0
- package/dist/components.js +38 -0
- package/dist/config.d.ts +100 -0
- package/dist/config.js +914 -0
- package/dist/core-access.d.ts +11 -0
- package/dist/core-access.js +34 -0
- package/dist/core-blocks.d.ts +24 -0
- package/dist/core-blocks.js +75 -0
- package/dist/core-fields.d.ts +36 -0
- package/dist/core-fields.js +134 -0
- package/dist/core-utils.d.ts +16 -0
- package/dist/core-utils.js +59 -0
- package/dist/data-collections.d.ts +200 -0
- package/dist/data-collections.js +625 -0
- package/dist/data-seed.d.ts +76 -0
- package/dist/data-seed.js +212 -0
- package/dist/data-test.d.ts +30 -0
- package/dist/data-test.js +1018 -0
- package/dist/fields.d.ts +36 -0
- package/dist/fields.js +134 -0
- package/dist/globals.d.ts +48 -0
- package/dist/globals.js +228 -0
- package/dist/hooks.d.ts +108 -0
- package/dist/hooks.js +196 -0
- package/dist/imagehash.d.ts +3 -0
- package/dist/imagehash.js +24 -0
- package/dist/import-map-provider.d.ts +20 -0
- package/dist/import-map-provider.js +26 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +38 -0
- package/dist/metadata.d.ts +122 -0
- package/dist/metadata.js +335 -0
- package/dist/pages.d.ts +323 -0
- package/dist/pages.js +1016 -0
- package/dist/render-components.d.ts +42 -0
- package/dist/render-components.js +144 -0
- package/dist/render-metadata.d.ts +122 -0
- package/dist/render-metadata.js +335 -0
- package/dist/render-pages.d.ts +574 -0
- package/dist/render-pages.js +1450 -0
- package/dist/render-utils.d.ts +158 -0
- package/dist/render-utils.js +341 -0
- package/dist/seed.d.ts +76 -0
- package/dist/seed.js +212 -0
- package/dist/server.d.ts +922 -0
- package/dist/server.js +2055 -0
- package/dist/test.d.ts +30 -0
- package/dist/test.js +1018 -0
- package/dist/translator.d.ts +2 -0
- package/dist/translator.js +24 -0
- package/dist/utils.d.ts +16 -0
- package/dist/utils.js +59 -0
- package/dist/with-www-config.d.ts +100 -0
- package/dist/with-www-config.js +914 -0
- package/package.json +246 -0
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
import { Metadata, MetadataRoute } from "next";
|
|
2
|
+
import { DataFromCollectionSlug, ImportMap, SanitizedConfig } from "payload";
|
|
3
|
+
import { ReactElement, ReactNode } from "react";
|
|
4
|
+
type BreadcrumbItem = {
|
|
5
|
+
label: string;
|
|
6
|
+
url: string;
|
|
7
|
+
};
|
|
8
|
+
type ArticleJsonLdEntry = {
|
|
9
|
+
type: "article";
|
|
10
|
+
id?: string;
|
|
11
|
+
schemaType?: "BlogPosting" | "Article" | "NewsArticle" | "TechArticle";
|
|
12
|
+
publisherName?: string;
|
|
13
|
+
publisherLogo?: string | null;
|
|
14
|
+
};
|
|
15
|
+
type WebSiteJsonLdEntry = {
|
|
16
|
+
type: "website";
|
|
17
|
+
id?: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
alternateName?: string;
|
|
20
|
+
};
|
|
21
|
+
type OrganizationJsonLdEntry = {
|
|
22
|
+
type: "organization";
|
|
23
|
+
id?: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
logo?: string;
|
|
26
|
+
sameAs?: string[];
|
|
27
|
+
};
|
|
28
|
+
type BreadcrumbsJsonLdEntry = {
|
|
29
|
+
type: "breadcrumbs";
|
|
30
|
+
id?: string;
|
|
31
|
+
items?: BreadcrumbItem[];
|
|
32
|
+
buildItems?: (doc: DataFromCollectionSlug<string>, url: string) => BreadcrumbItem[];
|
|
33
|
+
};
|
|
34
|
+
type CustomJsonLdEntry = {
|
|
35
|
+
type: "custom";
|
|
36
|
+
id?: string;
|
|
37
|
+
build: (ctx: {
|
|
38
|
+
doc: DataFromCollectionSlug<string>;
|
|
39
|
+
url: string;
|
|
40
|
+
locale: string;
|
|
41
|
+
siteUrl: string;
|
|
42
|
+
}) => Record<string, unknown>;
|
|
43
|
+
};
|
|
44
|
+
type JsonLdEntry = ArticleJsonLdEntry | WebSiteJsonLdEntry | OrganizationJsonLdEntry | BreadcrumbsJsonLdEntry | CustomJsonLdEntry;
|
|
45
|
+
type JsonLdOutput = {
|
|
46
|
+
id: string;
|
|
47
|
+
schema: Record<string, unknown>;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Minimal next-intl routing contract the lib reads. Hosts pass
|
|
51
|
+
* their `defineRouting({...})` result directly; the lib only needs
|
|
52
|
+
* the shape below.
|
|
53
|
+
*
|
|
54
|
+
* `localePrefix` accepts either the simple string form
|
|
55
|
+
* (`'always' | 'as-needed' | 'never'`) or next-intl's verbose
|
|
56
|
+
* `LocalePrefixConfigVerbose` shape (`{ mode, prefixes? }`). The lib
|
|
57
|
+
* normalizes both to a string `mode` internally.
|
|
58
|
+
*/
|
|
59
|
+
type LocalePrefixValue = "always" | "as-needed" | "never" | {
|
|
60
|
+
mode?: "always" | "as-needed" | "never";
|
|
61
|
+
};
|
|
62
|
+
type PageRouting = {
|
|
63
|
+
locales: readonly string[];
|
|
64
|
+
defaultLocale: string;
|
|
65
|
+
localePrefix?: LocalePrefixValue;
|
|
66
|
+
/** Optional human-readable labels per locale (used by the
|
|
67
|
+
* `<LocaleSwitcher>`). Falls back to the locale code when missing.
|
|
68
|
+
* Not part of next-intl's `defineRouting` shape — the host extends
|
|
69
|
+
* its routing object to include it (e.g. via a type assertion). */
|
|
70
|
+
labels?: Record<string, string>;
|
|
71
|
+
};
|
|
72
|
+
type MetadataOptions = {
|
|
73
|
+
urlPrefix?: string;
|
|
74
|
+
/** When true (default), the lib generates a `{type:'website'}` JSON-LD
|
|
75
|
+
* entry per page. Pass an array to specify entries; pass `false` to
|
|
76
|
+
* skip. */
|
|
77
|
+
jsonLd?: boolean | JsonLdEntry[];
|
|
78
|
+
changefreq?: MetadataRoute.Sitemap[number]["changeFrequency"];
|
|
79
|
+
priority?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Override the default `'website'` JSON-LD's `name` field. Only
|
|
82
|
+
* relevant when `jsonLd !== false` and no `name` is set on the
|
|
83
|
+
* auto-generated entry.
|
|
84
|
+
*/
|
|
85
|
+
websiteName?: string;
|
|
86
|
+
};
|
|
87
|
+
type ShowcaseOptions = {
|
|
88
|
+
/**
|
|
89
|
+
* Wrap the rendered page in a two-column layout with a sidebar
|
|
90
|
+
* that surfaces the page's metadata, JSON-LD, and a language
|
|
91
|
+
* switcher. Hosts that want a clean render (no sidebar) leave
|
|
92
|
+
* this `false` (the default). The demo's home page enables it
|
|
93
|
+
* so visitors can see every artifact the lib generates in one
|
|
94
|
+
* place.
|
|
95
|
+
*/
|
|
96
|
+
enabled?: boolean;
|
|
97
|
+
/** Heading shown above the metadata block. Default: `'Page metadata'`. */
|
|
98
|
+
metadataHeading?: string;
|
|
99
|
+
/** Heading shown above the JSON-LD block. Default: `'JSON-LD'`. */
|
|
100
|
+
jsonLdHeading?: string;
|
|
101
|
+
};
|
|
102
|
+
type CreateCollectionPageExportsArgs<S extends string = "pages"> = {
|
|
103
|
+
config: Promise<SanitizedConfig>;
|
|
104
|
+
/**
|
|
105
|
+
* Defaults to `'pages'`. The collection slug whose documents the
|
|
106
|
+
* page route renders.
|
|
107
|
+
*/
|
|
108
|
+
slug?: S;
|
|
109
|
+
/**
|
|
110
|
+
* The next-intl `defineRouting({...})` result from the host's
|
|
111
|
+
* `i18n/routing.ts`. Drives locale validation, URL building,
|
|
112
|
+
* hreflang alternates, and the language switcher.
|
|
113
|
+
*/
|
|
114
|
+
routing: PageRouting;
|
|
115
|
+
/**
|
|
116
|
+
* The host's Payload importMap. The lib uses this to resolve
|
|
117
|
+
* the collection's `custom.path` (the page renderer module) and
|
|
118
|
+
* the live-preview listener. Pass `import { importMap } from
|
|
119
|
+
* '@/app/(payload)/admin/importMap.js'` from the host's page
|
|
120
|
+
* file. Default: `{}` — the page renders without a live-preview
|
|
121
|
+
* listener and uses the lib's registered `custom.path` for the
|
|
122
|
+
* collection renderer (which requires its key to be in the
|
|
123
|
+
* supplied importMap).
|
|
124
|
+
*/
|
|
125
|
+
importMap?: ImportMap;
|
|
126
|
+
/**
|
|
127
|
+
* Optional custom path pointing at the host's render module for
|
|
128
|
+
* the collection. Overrides the lib's registered `custom.path`
|
|
129
|
+
* (which defaults to `PAGES_RENDER_PATH`). Use this when you've
|
|
130
|
+
* defined your own Server Component for the collection.
|
|
131
|
+
*/
|
|
132
|
+
renderPath?: string;
|
|
133
|
+
};
|
|
134
|
+
type CreateCollectionPageExportsDeps<S extends string> = {
|
|
135
|
+
/**
|
|
136
|
+
* Host's `getServerSideURL()` (returns the absolute site URL).
|
|
137
|
+
*/
|
|
138
|
+
getServerSideURL: () => string;
|
|
139
|
+
/**
|
|
140
|
+
* Host's `generateMeta({ doc, url, type, locale })` (returns Next.js
|
|
141
|
+
* `Metadata`). The `doc` is the host's typed collection document
|
|
142
|
+
* (e.g. `Post` for the posts collection, `Page` for pages) with
|
|
143
|
+
* localized fields already resolved for the active locale. Read
|
|
144
|
+
* `doc.title` directly as a string — no locale-lookup needed.
|
|
145
|
+
*/
|
|
146
|
+
generateMeta: (args: {
|
|
147
|
+
doc: DataFromCollectionSlug<S> | null;
|
|
148
|
+
url: string;
|
|
149
|
+
type: "website" | "article";
|
|
150
|
+
locale: string;
|
|
151
|
+
}) => Promise<Metadata>;
|
|
152
|
+
/**
|
|
153
|
+
* Override the metadata type passed to `generateMeta` and the
|
|
154
|
+
* JSON-LD entry default. Defaults to `'article'` for the
|
|
155
|
+
* `posts` collection, `'website'` everywhere else. Hosts that
|
|
156
|
+
* want to opt out (e.g. treat a Post like a WebPage) pass
|
|
157
|
+
* `'website'` explicitly here.
|
|
158
|
+
*/
|
|
159
|
+
metadataType?: "website" | "article";
|
|
160
|
+
/**
|
|
161
|
+
* Optional showcase configuration. When `enabled: true`, the
|
|
162
|
+
* default page renders inside a `<PageShowcase>` sidebar that
|
|
163
|
+
* surfaces the page's metadata, JSON-LD, and a language
|
|
164
|
+
* switcher — useful for demos and CMS previews. Default: off.
|
|
165
|
+
*/
|
|
166
|
+
showcase?: ShowcaseOptions;
|
|
167
|
+
/**
|
|
168
|
+
* Optional content injected after the rendered doc body when the
|
|
169
|
+
* page is the home route (slug = `''`). The lib calls the
|
|
170
|
+
* function with the resolved locale and the current doc (or
|
|
171
|
+
* `null` if no home doc exists). Hosts that want the home to
|
|
172
|
+
* surface additional content — recent pages, recent posts,
|
|
173
|
+
* navigation — pass a function here. The return value is
|
|
174
|
+
* rendered as a sibling of the lib's doc body inside the page
|
|
175
|
+
* (and inside the showcase's main column when showcase is on).
|
|
176
|
+
*/
|
|
177
|
+
homeExtras?: (args: {
|
|
178
|
+
locale: string;
|
|
179
|
+
doc: DataFromCollectionSlug<S> | null;
|
|
180
|
+
}) => ReactNode | Promise<ReactNode>;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Build a Pages (or any collection) page route's exports:
|
|
184
|
+
* `default` (the Page Server Component), `generateMetadata`,
|
|
185
|
+
* `generateStaticParams`, and `generateSitemap`.
|
|
186
|
+
*
|
|
187
|
+
* Designed for a next-intl layout: the page lives at
|
|
188
|
+
* `app/(frontend)/[locale]/[...slug]/page.tsx`. The catch-all slug
|
|
189
|
+
* handles both the home route (slug=[]) and any other doc. The lib
|
|
190
|
+
* reads `params.locale` and `params.slug` (string[]), validates
|
|
191
|
+
* the locale against `routing.locales`, fetches the doc, generates
|
|
192
|
+
* metadata + JSON-LD + hreflang alternates, and renders the
|
|
193
|
+
* resolved output.
|
|
194
|
+
*
|
|
195
|
+
* The host's `next-intl/routing` config is the single source of
|
|
196
|
+
* truth for the locale list and URL shape.
|
|
197
|
+
*
|
|
198
|
+
* // app/(frontend)/[locale]/[...slug]/page.tsx
|
|
199
|
+
* import { routing } from '@/i18n/routing'
|
|
200
|
+
* import { createCollectionPageExports } from '@justanarthur/payload-www/render-pages'
|
|
201
|
+
*
|
|
202
|
+
* const { default: Page, generateMetadata, generateStaticParams } =
|
|
203
|
+
* createCollectionPageExports(
|
|
204
|
+
* { config: configPromise, routing },
|
|
205
|
+
* { getServerSideURL, generateMeta, showcase: { enabled: true } }
|
|
206
|
+
* )
|
|
207
|
+
*
|
|
208
|
+
* { generateMetadata, generateStaticParams }
|
|
209
|
+
* Page
|
|
210
|
+
*/
|
|
211
|
+
declare function createCollectionPageExports<S extends string = "pages">({ slug, config: configPromise, routing, importMap: importMapArg, renderPath }: CreateCollectionPageExportsArgs<S>, deps: CreateCollectionPageExportsDeps<S>, options?: MetadataOptions): {
|
|
212
|
+
default: (props: {
|
|
213
|
+
params: Promise<{
|
|
214
|
+
locale?: string;
|
|
215
|
+
slug?: string[];
|
|
216
|
+
}>;
|
|
217
|
+
searchParams?: Promise<Record<string, string | string[] | undefined>>;
|
|
218
|
+
}) => Promise<ReactElement>;
|
|
219
|
+
generateMetadata: (props: {
|
|
220
|
+
params: Promise<{
|
|
221
|
+
locale?: string;
|
|
222
|
+
slug?: string[];
|
|
223
|
+
}>;
|
|
224
|
+
}) => Promise<Metadata>;
|
|
225
|
+
generateStaticParams: () => Promise<Array<{
|
|
226
|
+
slug?: string[];
|
|
227
|
+
locale: string;
|
|
228
|
+
}>>;
|
|
229
|
+
generateSitemap: () => Promise<MetadataRoute.Sitemap>;
|
|
230
|
+
generateJsonLd: (slugSegments: string[], doc: DataFromCollectionSlug<S>, locale: string) => Promise<JsonLdOutput[]>;
|
|
231
|
+
};
|
|
232
|
+
declare function addCollectionsToSitemap(exports: Array<{
|
|
233
|
+
default: () => Promise<MetadataRoute.Sitemap>;
|
|
234
|
+
generateSitemap: () => Promise<MetadataRoute.Sitemap>;
|
|
235
|
+
}>): {
|
|
236
|
+
default: () => Promise<MetadataRoute.Sitemap>;
|
|
237
|
+
generateSitemap: () => Promise<MetadataRoute.Sitemap>;
|
|
238
|
+
};
|
|
239
|
+
import { ImportMap as ImportMap2, SanitizedConfig as SanitizedConfig2 } from "payload";
|
|
240
|
+
import { HTMLAttributes, ReactElement as ReactElement2, ReactNode as ReactNode2 } from "react";
|
|
241
|
+
type CreateRootLayoutProvidersArgs = {
|
|
242
|
+
children: ReactNode2;
|
|
243
|
+
locale: string;
|
|
244
|
+
/** Messages for the active locale — hosts pass these into
|
|
245
|
+
* `NextIntlClientProvider`. The lib fetches them once per request
|
|
246
|
+
* and exposes them here so the host doesn't have to. */
|
|
247
|
+
messages: Record<string, any>;
|
|
248
|
+
/** Whether Next.js draft mode is currently active. Hosts typically
|
|
249
|
+
* pass this to `<AdminBar preview={draftMode} />`. */
|
|
250
|
+
draftMode: boolean;
|
|
251
|
+
};
|
|
252
|
+
type CreateRootLayoutExportsArgs = {
|
|
253
|
+
/** Payload config promise — same shape `createCollectionPageExports` uses. */
|
|
254
|
+
config: Promise<SanitizedConfig2>;
|
|
255
|
+
/** next-intl routing config (locales + defaultLocale + localePrefix).
|
|
256
|
+
* Same `PageRouting` shape the rest of the lib uses. */
|
|
257
|
+
routing: PageRouting;
|
|
258
|
+
/**
|
|
259
|
+
* The host's Payload importMap. The lib uses this to resolve
|
|
260
|
+
* header / footer globals' `custom.path` entries through
|
|
261
|
+
* `renderGlobalModule`. Pass `import { importMap } from
|
|
262
|
+
* '@/app/(payload)/admin/importMap.js'` (or equivalent path) from
|
|
263
|
+
* the host's layout file. Default: `{}` — header/footer globals
|
|
264
|
+
* with `custom.path` set won't render unless the matching entry
|
|
265
|
+
* is in the supplied importMap.
|
|
266
|
+
*/
|
|
267
|
+
importMap?: ImportMap2;
|
|
268
|
+
/**
|
|
269
|
+
* Single composition point for the entire provider tree —
|
|
270
|
+
* AdminBar, NextIntlClientProvider, theme, analytics, etc.
|
|
271
|
+
* Receives `draftMode` so the host can render `<AdminBar>` here
|
|
272
|
+
* without re-reading from `next/headers` themselves.
|
|
273
|
+
*
|
|
274
|
+
* Default: identity (`({ children }) => children`) — wraps nothing.
|
|
275
|
+
*/
|
|
276
|
+
providers?: (args: CreateRootLayoutProvidersArgs) => ReactNode2;
|
|
277
|
+
/**
|
|
278
|
+
* Optional content rendered inside `<head>`. Hosts drop favicons,
|
|
279
|
+
* `<link rel>` tags, theme initialization, etc.
|
|
280
|
+
*
|
|
281
|
+
* Default: no extra head content (lib doesn't ship favicons —
|
|
282
|
+
* that's host content).
|
|
283
|
+
*/
|
|
284
|
+
head?: () => ReactNode2;
|
|
285
|
+
/**
|
|
286
|
+
* Optional `<html>` attribute overrides. The lib already applies
|
|
287
|
+
* `lang={locale}` and `suppressHydrationWarning` — host additions
|
|
288
|
+
* are merged on top.
|
|
289
|
+
*/
|
|
290
|
+
htmlAttrs?: (locale: string) => HTMLAttributes<HTMLHtmlElement>;
|
|
291
|
+
};
|
|
292
|
+
type CreateRootLayoutExportsReturn = {
|
|
293
|
+
/** Default for `app/(frontend)/[locale]/layout.tsx`. */
|
|
294
|
+
default: (props: {
|
|
295
|
+
children: ReactNode2;
|
|
296
|
+
params: Promise<{
|
|
297
|
+
locale: string;
|
|
298
|
+
}>;
|
|
299
|
+
}) => Promise<ReactElement2>;
|
|
300
|
+
/** Pre-render every locale at build time. */
|
|
301
|
+
generateStaticParams: () => Array<{
|
|
302
|
+
locale: string;
|
|
303
|
+
}>;
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Build the lib's root layout exports. Renders:
|
|
307
|
+
*
|
|
308
|
+
* <html {htmlAttrs}>
|
|
309
|
+
* <head>
|
|
310
|
+
* {head?.()}
|
|
311
|
+
* </head>
|
|
312
|
+
* <body>
|
|
313
|
+
* {providers({ children: (
|
|
314
|
+
* <Header data={...} locale={...} />
|
|
315
|
+
* {children}
|
|
316
|
+
* <Footer data={...} locale={...} />
|
|
317
|
+
* ), locale, messages, draftMode })}
|
|
318
|
+
* </body>
|
|
319
|
+
* </html>
|
|
320
|
+
*
|
|
321
|
+
* Header and Footer are fetched per-locale via the lib's
|
|
322
|
+
* `queryGlobal` and rendered through their globals' `custom.path`
|
|
323
|
+
* — the same mechanism pages/posts use. Hosts override visuals by
|
|
324
|
+
* setting a different `renderPath` on the global via
|
|
325
|
+
* `createHeaderGlobal({ renderPath })` / `createFooterGlobal({ ... })`.
|
|
326
|
+
*
|
|
327
|
+
* Usage — minimal:
|
|
328
|
+
*
|
|
329
|
+
* // app/(frontend)/[locale]/layout.tsx
|
|
330
|
+
* import { createRootLayoutExports } from '@justanarthur/payload-www/render-pages'
|
|
331
|
+
* import { NextIntlClientProvider } from 'next-intl'
|
|
332
|
+
* import { AdminBar } from '@justanarthur/payload-www/render-components'
|
|
333
|
+
* import { routing } from '@/i18n/routing'
|
|
334
|
+
* import configPromise from '@payload-config'
|
|
335
|
+
*
|
|
336
|
+
* const { default: RootLayout, generateStaticParams } = createRootLayoutExports({
|
|
337
|
+
* config: configPromise,
|
|
338
|
+
* routing,
|
|
339
|
+
* providers: ({ children, locale, messages, draftMode }) => (
|
|
340
|
+
* <>
|
|
341
|
+
* <AdminBar preview={draftMode} />
|
|
342
|
+
* <NextIntlClientProvider locale={locale} messages={messages}>
|
|
343
|
+
* {children}
|
|
344
|
+
* </NextIntlClientProvider>
|
|
345
|
+
* </>
|
|
346
|
+
* ),
|
|
347
|
+
* head: () => <link href="/favicon.ico" rel="icon" sizes="32x32" />
|
|
348
|
+
* })
|
|
349
|
+
*
|
|
350
|
+
* { generateStaticParams }
|
|
351
|
+
* RootLayout
|
|
352
|
+
*/
|
|
353
|
+
declare function createRootLayoutExports(args: CreateRootLayoutExportsArgs): CreateRootLayoutExportsReturn;
|
|
354
|
+
import { ImportMap as ImportMap3, SanitizedConfig as SanitizedConfig3 } from "payload";
|
|
355
|
+
import { ReactElement as ReactElement3 } from "react";
|
|
356
|
+
type CreateStaticPageExportsArgs = {
|
|
357
|
+
/**
|
|
358
|
+
* The `kind` discriminator to fetch from the `staticPages`
|
|
359
|
+
* collection. Default: `'not-found'`. The factory fetches the
|
|
360
|
+
* row where `kind === {kind}` and renders its `blocks` via
|
|
361
|
+
* `PagesPage` (the same component the catch-all dynamic route
|
|
362
|
+
* uses).
|
|
363
|
+
*/
|
|
364
|
+
kind?: string;
|
|
365
|
+
/**
|
|
366
|
+
* Payload config promise (same shape as `createCollectionPageExports`).
|
|
367
|
+
*/
|
|
368
|
+
config: Promise<SanitizedConfig3>;
|
|
369
|
+
/**
|
|
370
|
+
* Host's Payload importMap. Same purpose as the Pages factory.
|
|
371
|
+
* Default: `{}`.
|
|
372
|
+
*/
|
|
373
|
+
importMap?: ImportMap3;
|
|
374
|
+
};
|
|
375
|
+
/**
|
|
376
|
+
* Build a static page's default — designed for Next.js
|
|
377
|
+
* `not-found.tsx` / `error.tsx` (and similar) route files. Static
|
|
378
|
+
* pages are addressed by a `kind` discriminator, not a slug, so
|
|
379
|
+
* they don't need metadata, sitemap, or static-params plumbing.
|
|
380
|
+
*
|
|
381
|
+
* Per Next.js docs, not-found/error components receive **no
|
|
382
|
+
* props**. The active locale is read via `getLocale()` from
|
|
383
|
+
* `next-intl/server`, which reads from the request config
|
|
384
|
+
* populated by middleware from the `[locale]` URL segment (the
|
|
385
|
+
* host's `i18n/request.ts` handles invalid-locale fallback
|
|
386
|
+
* before this returns).
|
|
387
|
+
*
|
|
388
|
+
* // app/(frontend)/[locale]/not-found.tsx
|
|
389
|
+
* import configPromise from '@payload-config'
|
|
390
|
+
* import { createStaticPageExports } from '@justanarthur/payload-www/render-pages'
|
|
391
|
+
* import { importMap } from '@/app/(payload)/admin/importMap.js'
|
|
392
|
+
*
|
|
393
|
+
* const { default: NotFound } = createStaticPageExports({
|
|
394
|
+
* config: configPromise,
|
|
395
|
+
* importMap,
|
|
396
|
+
* })
|
|
397
|
+
* NotFound
|
|
398
|
+
*
|
|
399
|
+
* // app/(frontend)/[locale]/server-error.tsx
|
|
400
|
+
* const { default: ServerError } = createStaticPageExports({
|
|
401
|
+
* kind: 'server-error',
|
|
402
|
+
* config: configPromise,
|
|
403
|
+
* importMap,
|
|
404
|
+
* })
|
|
405
|
+
* ServerError
|
|
406
|
+
*/
|
|
407
|
+
declare function createStaticPageExports({ kind, config: configPromise, importMap: importMapArg }: CreateStaticPageExportsArgs): {
|
|
408
|
+
default: () => Promise<ReactElement3>;
|
|
409
|
+
};
|
|
410
|
+
import { Metadata as Metadata2 } from "next";
|
|
411
|
+
import { ReactElement as ReactElement4, ReactNode as ReactNode3 } from "react";
|
|
412
|
+
type PageShowcaseProps = {
|
|
413
|
+
/** The lib-rendered page body (RenderBlocks output + JSON-LD scripts). */
|
|
414
|
+
children: ReactNode3;
|
|
415
|
+
/**
|
|
416
|
+
* The Next.js `Metadata` object resolved by `createCollectionPageExports`'s
|
|
417
|
+
* `generateMetadata`. The showcase renders the title, description,
|
|
418
|
+
* Open Graph, and Twitter Card entries as a labeled list.
|
|
419
|
+
*/
|
|
420
|
+
metadata: Metadata2;
|
|
421
|
+
/**
|
|
422
|
+
* The JSON-LD entries resolved by the lib. Rendered as `<pre>`
|
|
423
|
+
* blocks inside a `<details>` element so visitors can see the
|
|
424
|
+
* schema.org payload without it being a wall of JSON.
|
|
425
|
+
*/
|
|
426
|
+
jsonLd: Array<{
|
|
427
|
+
id: string;
|
|
428
|
+
schema: Record<string, unknown>;
|
|
429
|
+
}>;
|
|
430
|
+
/**
|
|
431
|
+
* The `<LocaleSwitcher>` element the lib built from the page's
|
|
432
|
+
* hreflang alternates. Mounted at the top of the sidebar.
|
|
433
|
+
*/
|
|
434
|
+
localeSwitcher: ReactNode3;
|
|
435
|
+
/** Heading above the metadata block. Default: `'Page metadata'`. */
|
|
436
|
+
metadataHeading?: string;
|
|
437
|
+
/** Heading above the JSON-LD block. Default: `'JSON-LD'`. */
|
|
438
|
+
jsonLdHeading?: string;
|
|
439
|
+
};
|
|
440
|
+
/**
|
|
441
|
+
* Two-column showcase layout that surfaces the page's metadata,
|
|
442
|
+
* JSON-LD, and language switcher alongside the rendered body. Used
|
|
443
|
+
* by the lib's `createCollectionPageExports` when the host passes
|
|
444
|
+
* `showcase: { enabled: true }`. The default render is the bare
|
|
445
|
+
* doc body + JSON-LD scripts (no sidebar).
|
|
446
|
+
*
|
|
447
|
+
* The layout is intentionally minimal — a `<div class="page-showcase">`
|
|
448
|
+
* with `main` + `aside` columns, no styles. Hosts that want a fancier
|
|
449
|
+
* layout override via their own CSS.
|
|
450
|
+
*/
|
|
451
|
+
declare function PageShowcase({ children, metadata, jsonLd, localeSwitcher, metadataHeading, jsonLdHeading }: PageShowcaseProps): ReactElement4;
|
|
452
|
+
import { ReactElement as ReactElement5 } from "react";
|
|
453
|
+
import { SanitizedConfig as SanitizedConfig4 } from "payload";
|
|
454
|
+
type PagesPageProps = {
|
|
455
|
+
/**
|
|
456
|
+
* The resolved page document. The host's `[slug]/page.tsx` route
|
|
457
|
+
* handler is responsible for fetching the doc (via Payload's
|
|
458
|
+
* `getPayload` or via the lib's `createCollectionPageExports`'s
|
|
459
|
+
* `generateMetadata` helper). This component just renders the
|
|
460
|
+
* visual body.
|
|
461
|
+
*/
|
|
462
|
+
doc: Record<string, any> | null;
|
|
463
|
+
/**
|
|
464
|
+
* Resolved locale string (already validated upstream by the host's
|
|
465
|
+
* `[locale]` route segment).
|
|
466
|
+
*/
|
|
467
|
+
locale: string;
|
|
468
|
+
/**
|
|
469
|
+
* Block components keyed by `blockType`. The host passes the same
|
|
470
|
+
* `importMap` it uses everywhere else; the lib's `RenderBlocks`
|
|
471
|
+
* resolves each block against the map.
|
|
472
|
+
*/
|
|
473
|
+
importMap: Record<string, unknown>;
|
|
474
|
+
config: SanitizedConfig4;
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* Default visual body for the Pages collection. Renders the doc's
|
|
478
|
+
* `blocks` field via the lib's `RenderBlocks`. Hosts can replace
|
|
479
|
+
* this by setting a different `custom.path` on their own Pages
|
|
480
|
+
* collection (via the lib's `createPagesCollection` factory) and
|
|
481
|
+
* pointing it at their own Server Component.
|
|
482
|
+
*/
|
|
483
|
+
declare function PagesPage({ doc,...props }: PagesPageProps): Promise<ReactElement5>;
|
|
484
|
+
import { ReactElement as ReactElement6 } from "react";
|
|
485
|
+
type PostsPageProps = {
|
|
486
|
+
/**
|
|
487
|
+
* The resolved post document. The host's `/blog/[...slug]/page.tsx`
|
|
488
|
+
* route handler is responsible for fetching the doc (via Payload's
|
|
489
|
+
* `getPayload` or via the lib's `createCollectionPageExports`'s
|
|
490
|
+
* `generateMetadata` helper). This component just renders the
|
|
491
|
+
* visual body.
|
|
492
|
+
*/
|
|
493
|
+
doc: Record<string, any> | null;
|
|
494
|
+
/**
|
|
495
|
+
* Resolved locale string (already validated upstream by the host's
|
|
496
|
+
* `[locale]` route segment). Unused by this default render — kept
|
|
497
|
+
* on the signature so hosts can swap in their own component
|
|
498
|
+
* without changing the importMap entry.
|
|
499
|
+
*/
|
|
500
|
+
locale: string;
|
|
501
|
+
/**
|
|
502
|
+
* Payload's generated importMap. Reserved for hosts that want to
|
|
503
|
+
* extend this component with custom Lexical converters via the
|
|
504
|
+
* `RichText` `converters` prop. Not consumed by the default render.
|
|
505
|
+
*/
|
|
506
|
+
importMap: Record<string, unknown>;
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* Default visual body for the Posts collection. Renders the doc's
|
|
510
|
+
* `title`, optional `excerpt`, and `content` (Lexical richText)
|
|
511
|
+
* via Payload's official `<RichText>` component.
|
|
512
|
+
*
|
|
513
|
+
* Hosts can replace this by setting a different `custom.path` on
|
|
514
|
+
* their own Posts collection (via the lib's `createPostsCollection`
|
|
515
|
+
* factory) and pointing it at their own Server Component.
|
|
516
|
+
*
|
|
517
|
+
* The lib's `<RichText>` import is the client-safe React renderer
|
|
518
|
+
* from `@payloadcms/richtext-lexical/react` — no client component
|
|
519
|
+
* here. The component serializes on the server.
|
|
520
|
+
*/
|
|
521
|
+
declare function PostsPage({ doc, locale, importMap: _importMap }: PostsPageProps): Promise<ReactElement6>;
|
|
522
|
+
import { ReactElement as ReactElement7 } from "react";
|
|
523
|
+
type HeaderPageProps = {
|
|
524
|
+
/** The resolved Header global document. `null` if the host hasn't
|
|
525
|
+
* created a Header yet. */
|
|
526
|
+
data: Record<string, any> | null;
|
|
527
|
+
/**
|
|
528
|
+
* Resolved locale string. The default header visual uses this for
|
|
529
|
+
* per-locale labels via next-intl (if the host has it wired). The
|
|
530
|
+
* default ships without a label dictionary — the host can override
|
|
531
|
+
* by setting a different `custom.path` on the header global.
|
|
532
|
+
*/
|
|
533
|
+
locale: string;
|
|
534
|
+
};
|
|
535
|
+
/**
|
|
536
|
+
* Default visual for the `header` global. Renders the header's
|
|
537
|
+
* `nav` blocks (a flat list of `navItem` and `navColumn` blocks) as
|
|
538
|
+
* a simple `<nav>` element.
|
|
539
|
+
*
|
|
540
|
+
* Hosts can replace this visual by setting a different `custom.path`
|
|
541
|
+
* on their own header global (via the lib's `createHeaderGlobal`
|
|
542
|
+
* factory).
|
|
543
|
+
*/
|
|
544
|
+
declare function HeaderPage({ data, locale: _locale }: HeaderPageProps): ReactElement7;
|
|
545
|
+
import { ReactElement as ReactElement8 } from "react";
|
|
546
|
+
type FooterPageProps = {
|
|
547
|
+
/** The resolved Footer global document. `null` if the host hasn't
|
|
548
|
+
* created a Footer yet. */
|
|
549
|
+
data: Record<string, any> | null;
|
|
550
|
+
locale: string;
|
|
551
|
+
};
|
|
552
|
+
/**
|
|
553
|
+
* Default visual for the `footer` global. Renders the footer's
|
|
554
|
+
* `nav` blocks (a flat list of `navItem` and `navColumn` blocks)
|
|
555
|
+
* as a simple `<footer>` element.
|
|
556
|
+
*
|
|
557
|
+
* Hosts can replace this visual by setting a different `custom.path`
|
|
558
|
+
* on their own footer global (via the lib's `createFooterGlobal`
|
|
559
|
+
* factory).
|
|
560
|
+
*/
|
|
561
|
+
declare function FooterPage({ data, locale: _locale }: FooterPageProps): ReactElement8;
|
|
562
|
+
declare const PageShowcase2: typeof PageShowcase;
|
|
563
|
+
declare const _default: {
|
|
564
|
+
addCollectionsToSitemap: typeof addCollectionsToSitemap;
|
|
565
|
+
createCollectionPageExports: typeof createCollectionPageExports;
|
|
566
|
+
createRootLayoutExports: typeof createRootLayoutExports;
|
|
567
|
+
createStaticPageExports: typeof createStaticPageExports;
|
|
568
|
+
HeaderPage: typeof HeaderPage;
|
|
569
|
+
FooterPage: typeof FooterPage;
|
|
570
|
+
PagesPage: typeof PagesPage;
|
|
571
|
+
PostsPage: typeof PostsPage;
|
|
572
|
+
PageShowcase2: typeof PageShowcase;
|
|
573
|
+
};
|
|
574
|
+
export { _default as default, createStaticPageExports, createRootLayoutExports, createCollectionPageExports, addCollectionsToSitemap, ShowcaseOptions, PostsPage, PagesPage, PageShowcaseProps, PageShowcase2 as PageShowcase, PageRouting, MetadataOptions, JsonLdOutput, JsonLdEntry, HeaderPage, FooterPage, CreateStaticPageExportsArgs, CreateRootLayoutProvidersArgs, CreateRootLayoutExportsReturn, CreateRootLayoutExportsArgs, CreateCollectionPageExportsDeps, CreateCollectionPageExportsArgs };
|