@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
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,922 @@
|
|
|
1
|
+
import { Block as Block3, CollectionConfig as CollectionConfig4, Config, GlobalConfig as GlobalConfig3, Plugin } from "payload";
|
|
2
|
+
import { Metadata, MetadataRoute } from "next";
|
|
3
|
+
import { DataFromCollectionSlug, ImportMap, SanitizedConfig } from "payload";
|
|
4
|
+
import { ReactElement, ReactNode } from "react";
|
|
5
|
+
type ArticleLdOptions = {
|
|
6
|
+
doc: Record<string, any>;
|
|
7
|
+
url: string;
|
|
8
|
+
locale: string;
|
|
9
|
+
siteUrl: string;
|
|
10
|
+
type?: "BlogPosting" | "Article" | "NewsArticle" | "TechArticle";
|
|
11
|
+
publisherName?: string;
|
|
12
|
+
publisherLogo?: string | null;
|
|
13
|
+
};
|
|
14
|
+
declare function buildArticleLd({ doc, url, locale, siteUrl, type, publisherName, publisherLogo }: ArticleLdOptions): Record<string, unknown>;
|
|
15
|
+
type BreadcrumbItem = {
|
|
16
|
+
label: string;
|
|
17
|
+
url: string;
|
|
18
|
+
};
|
|
19
|
+
declare function buildBreadcrumbsLd({ items, currentUrl }: {
|
|
20
|
+
items: BreadcrumbItem[];
|
|
21
|
+
currentUrl: string;
|
|
22
|
+
}): Record<string, unknown>;
|
|
23
|
+
declare function buildOrganizationLd({ siteUrl, name, logo, sameAs }: {
|
|
24
|
+
siteUrl: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
logo?: string;
|
|
27
|
+
sameAs?: string[];
|
|
28
|
+
}): Record<string, unknown>;
|
|
29
|
+
type PageExtendProps = {
|
|
30
|
+
importMap: ImportMap;
|
|
31
|
+
config: SanitizedConfig;
|
|
32
|
+
locale: string;
|
|
33
|
+
};
|
|
34
|
+
type ArticleJsonLdEntry = {
|
|
35
|
+
type: "article";
|
|
36
|
+
id?: string;
|
|
37
|
+
schemaType?: "BlogPosting" | "Article" | "NewsArticle" | "TechArticle";
|
|
38
|
+
publisherName?: string;
|
|
39
|
+
publisherLogo?: string | null;
|
|
40
|
+
};
|
|
41
|
+
type WebSiteJsonLdEntry = {
|
|
42
|
+
type: "website";
|
|
43
|
+
id?: string;
|
|
44
|
+
name?: string;
|
|
45
|
+
alternateName?: string;
|
|
46
|
+
};
|
|
47
|
+
type OrganizationJsonLdEntry = {
|
|
48
|
+
type: "organization";
|
|
49
|
+
id?: string;
|
|
50
|
+
name?: string;
|
|
51
|
+
logo?: string;
|
|
52
|
+
sameAs?: string[];
|
|
53
|
+
};
|
|
54
|
+
type BreadcrumbsJsonLdEntry = {
|
|
55
|
+
type: "breadcrumbs";
|
|
56
|
+
id?: string;
|
|
57
|
+
items?: BreadcrumbItem[];
|
|
58
|
+
buildItems?: (doc: DataFromCollectionSlug<string>, url: string) => BreadcrumbItem[];
|
|
59
|
+
};
|
|
60
|
+
type CustomJsonLdEntry = {
|
|
61
|
+
type: "custom";
|
|
62
|
+
id?: string;
|
|
63
|
+
build: (ctx: {
|
|
64
|
+
doc: DataFromCollectionSlug<string>;
|
|
65
|
+
url: string;
|
|
66
|
+
locale: string;
|
|
67
|
+
siteUrl: string;
|
|
68
|
+
}) => Record<string, unknown>;
|
|
69
|
+
};
|
|
70
|
+
type JsonLdEntry = ArticleJsonLdEntry | WebSiteJsonLdEntry | OrganizationJsonLdEntry | BreadcrumbsJsonLdEntry | CustomJsonLdEntry;
|
|
71
|
+
type JsonLdOutput = {
|
|
72
|
+
id: string;
|
|
73
|
+
schema: Record<string, unknown>;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Minimal next-intl routing contract the lib reads. Hosts pass
|
|
77
|
+
* their `defineRouting({...})` result directly; the lib only needs
|
|
78
|
+
* the shape below.
|
|
79
|
+
*
|
|
80
|
+
* `localePrefix` accepts either the simple string form
|
|
81
|
+
* (`'always' | 'as-needed' | 'never'`) or next-intl's verbose
|
|
82
|
+
* `LocalePrefixConfigVerbose` shape (`{ mode, prefixes? }`). The lib
|
|
83
|
+
* normalizes both to a string `mode` internally.
|
|
84
|
+
*/
|
|
85
|
+
type LocalePrefixValue = "always" | "as-needed" | "never" | {
|
|
86
|
+
mode?: "always" | "as-needed" | "never";
|
|
87
|
+
};
|
|
88
|
+
type PageRouting = {
|
|
89
|
+
locales: readonly string[];
|
|
90
|
+
defaultLocale: string;
|
|
91
|
+
localePrefix?: LocalePrefixValue;
|
|
92
|
+
/** Optional human-readable labels per locale (used by the
|
|
93
|
+
* `<LocaleSwitcher>`). Falls back to the locale code when missing.
|
|
94
|
+
* Not part of next-intl's `defineRouting` shape — the host extends
|
|
95
|
+
* its routing object to include it (e.g. via a type assertion). */
|
|
96
|
+
labels?: Record<string, string>;
|
|
97
|
+
};
|
|
98
|
+
type MetadataOptions = {
|
|
99
|
+
urlPrefix?: string;
|
|
100
|
+
/** When true (default), the lib generates a `{type:'website'}` JSON-LD
|
|
101
|
+
* entry per page. Pass an array to specify entries; pass `false` to
|
|
102
|
+
* skip. */
|
|
103
|
+
jsonLd?: boolean | JsonLdEntry[];
|
|
104
|
+
changefreq?: MetadataRoute.Sitemap[number]["changeFrequency"];
|
|
105
|
+
priority?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Override the default `'website'` JSON-LD's `name` field. Only
|
|
108
|
+
* relevant when `jsonLd !== false` and no `name` is set on the
|
|
109
|
+
* auto-generated entry.
|
|
110
|
+
*/
|
|
111
|
+
websiteName?: string;
|
|
112
|
+
};
|
|
113
|
+
type ShowcaseOptions = {
|
|
114
|
+
/**
|
|
115
|
+
* Wrap the rendered page in a two-column layout with a sidebar
|
|
116
|
+
* that surfaces the page's metadata, JSON-LD, and a language
|
|
117
|
+
* switcher. Hosts that want a clean render (no sidebar) leave
|
|
118
|
+
* this `false` (the default). The demo's home page enables it
|
|
119
|
+
* so visitors can see every artifact the lib generates in one
|
|
120
|
+
* place.
|
|
121
|
+
*/
|
|
122
|
+
enabled?: boolean;
|
|
123
|
+
/** Heading shown above the metadata block. Default: `'Page metadata'`. */
|
|
124
|
+
metadataHeading?: string;
|
|
125
|
+
/** Heading shown above the JSON-LD block. Default: `'JSON-LD'`. */
|
|
126
|
+
jsonLdHeading?: string;
|
|
127
|
+
};
|
|
128
|
+
type CreateCollectionPageExportsArgs<S extends string = "pages"> = {
|
|
129
|
+
config: Promise<SanitizedConfig>;
|
|
130
|
+
/**
|
|
131
|
+
* Defaults to `'pages'`. The collection slug whose documents the
|
|
132
|
+
* page route renders.
|
|
133
|
+
*/
|
|
134
|
+
slug?: S;
|
|
135
|
+
/**
|
|
136
|
+
* The next-intl `defineRouting({...})` result from the host's
|
|
137
|
+
* `i18n/routing.ts`. Drives locale validation, URL building,
|
|
138
|
+
* hreflang alternates, and the language switcher.
|
|
139
|
+
*/
|
|
140
|
+
routing: PageRouting;
|
|
141
|
+
/**
|
|
142
|
+
* The host's Payload importMap. The lib uses this to resolve
|
|
143
|
+
* the collection's `custom.path` (the page renderer module) and
|
|
144
|
+
* the live-preview listener. Pass `import { importMap } from
|
|
145
|
+
* '@/app/(payload)/admin/importMap.js'` from the host's page
|
|
146
|
+
* file. Default: `{}` — the page renders without a live-preview
|
|
147
|
+
* listener and uses the lib's registered `custom.path` for the
|
|
148
|
+
* collection renderer (which requires its key to be in the
|
|
149
|
+
* supplied importMap).
|
|
150
|
+
*/
|
|
151
|
+
importMap?: ImportMap;
|
|
152
|
+
/**
|
|
153
|
+
* Optional custom path pointing at the host's render module for
|
|
154
|
+
* the collection. Overrides the lib's registered `custom.path`
|
|
155
|
+
* (which defaults to `PAGES_RENDER_PATH`). Use this when you've
|
|
156
|
+
* defined your own Server Component for the collection.
|
|
157
|
+
*/
|
|
158
|
+
renderPath?: string;
|
|
159
|
+
};
|
|
160
|
+
type CreateCollectionPageExportsDeps<S extends string> = {
|
|
161
|
+
/**
|
|
162
|
+
* Host's `getServerSideURL()` (returns the absolute site URL).
|
|
163
|
+
*/
|
|
164
|
+
getServerSideURL: () => string;
|
|
165
|
+
/**
|
|
166
|
+
* Host's `generateMeta({ doc, url, type, locale })` (returns Next.js
|
|
167
|
+
* `Metadata`). The `doc` is the host's typed collection document
|
|
168
|
+
* (e.g. `Post` for the posts collection, `Page` for pages) with
|
|
169
|
+
* localized fields already resolved for the active locale. Read
|
|
170
|
+
* `doc.title` directly as a string — no locale-lookup needed.
|
|
171
|
+
*/
|
|
172
|
+
generateMeta: (args: {
|
|
173
|
+
doc: DataFromCollectionSlug<S> | null;
|
|
174
|
+
url: string;
|
|
175
|
+
type: "website" | "article";
|
|
176
|
+
locale: string;
|
|
177
|
+
}) => Promise<Metadata>;
|
|
178
|
+
/**
|
|
179
|
+
* Override the metadata type passed to `generateMeta` and the
|
|
180
|
+
* JSON-LD entry default. Defaults to `'article'` for the
|
|
181
|
+
* `posts` collection, `'website'` everywhere else. Hosts that
|
|
182
|
+
* want to opt out (e.g. treat a Post like a WebPage) pass
|
|
183
|
+
* `'website'` explicitly here.
|
|
184
|
+
*/
|
|
185
|
+
metadataType?: "website" | "article";
|
|
186
|
+
/**
|
|
187
|
+
* Optional showcase configuration. When `enabled: true`, the
|
|
188
|
+
* default page renders inside a `<PageShowcase>` sidebar that
|
|
189
|
+
* surfaces the page's metadata, JSON-LD, and a language
|
|
190
|
+
* switcher — useful for demos and CMS previews. Default: off.
|
|
191
|
+
*/
|
|
192
|
+
showcase?: ShowcaseOptions;
|
|
193
|
+
/**
|
|
194
|
+
* Optional content injected after the rendered doc body when the
|
|
195
|
+
* page is the home route (slug = `''`). The lib calls the
|
|
196
|
+
* function with the resolved locale and the current doc (or
|
|
197
|
+
* `null` if no home doc exists). Hosts that want the home to
|
|
198
|
+
* surface additional content — recent pages, recent posts,
|
|
199
|
+
* navigation — pass a function here. The return value is
|
|
200
|
+
* rendered as a sibling of the lib's doc body inside the page
|
|
201
|
+
* (and inside the showcase's main column when showcase is on).
|
|
202
|
+
*/
|
|
203
|
+
homeExtras?: (args: {
|
|
204
|
+
locale: string;
|
|
205
|
+
doc: DataFromCollectionSlug<S> | null;
|
|
206
|
+
}) => ReactNode | Promise<ReactNode>;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Build a Pages (or any collection) page route's exports:
|
|
210
|
+
* `default` (the Page Server Component), `generateMetadata`,
|
|
211
|
+
* `generateStaticParams`, and `generateSitemap`.
|
|
212
|
+
*
|
|
213
|
+
* Designed for a next-intl layout: the page lives at
|
|
214
|
+
* `app/(frontend)/[locale]/[...slug]/page.tsx`. The catch-all slug
|
|
215
|
+
* handles both the home route (slug=[]) and any other doc. The lib
|
|
216
|
+
* reads `params.locale` and `params.slug` (string[]), validates
|
|
217
|
+
* the locale against `routing.locales`, fetches the doc, generates
|
|
218
|
+
* metadata + JSON-LD + hreflang alternates, and renders the
|
|
219
|
+
* resolved output.
|
|
220
|
+
*
|
|
221
|
+
* The host's `next-intl/routing` config is the single source of
|
|
222
|
+
* truth for the locale list and URL shape.
|
|
223
|
+
*
|
|
224
|
+
* // app/(frontend)/[locale]/[...slug]/page.tsx
|
|
225
|
+
* import { routing } from '@/i18n/routing'
|
|
226
|
+
* import { createCollectionPageExports } from '@justanarthur/payload-www/render-pages'
|
|
227
|
+
*
|
|
228
|
+
* const { default: Page, generateMetadata, generateStaticParams } =
|
|
229
|
+
* createCollectionPageExports(
|
|
230
|
+
* { config: configPromise, routing },
|
|
231
|
+
* { getServerSideURL, generateMeta, showcase: { enabled: true } }
|
|
232
|
+
* )
|
|
233
|
+
*
|
|
234
|
+
* { generateMetadata, generateStaticParams }
|
|
235
|
+
* Page
|
|
236
|
+
*/
|
|
237
|
+
declare function createCollectionPageExports<S extends string = "pages">({ slug, config: configPromise, routing, importMap: importMapArg, renderPath }: CreateCollectionPageExportsArgs<S>, deps: CreateCollectionPageExportsDeps<S>, options?: MetadataOptions): {
|
|
238
|
+
default: (props: {
|
|
239
|
+
params: Promise<{
|
|
240
|
+
locale?: string;
|
|
241
|
+
slug?: string[];
|
|
242
|
+
}>;
|
|
243
|
+
searchParams?: Promise<Record<string, string | string[] | undefined>>;
|
|
244
|
+
}) => Promise<ReactElement>;
|
|
245
|
+
generateMetadata: (props: {
|
|
246
|
+
params: Promise<{
|
|
247
|
+
locale?: string;
|
|
248
|
+
slug?: string[];
|
|
249
|
+
}>;
|
|
250
|
+
}) => Promise<Metadata>;
|
|
251
|
+
generateStaticParams: () => Promise<Array<{
|
|
252
|
+
slug?: string[];
|
|
253
|
+
locale: string;
|
|
254
|
+
}>>;
|
|
255
|
+
generateSitemap: () => Promise<MetadataRoute.Sitemap>;
|
|
256
|
+
generateJsonLd: (slugSegments: string[], doc: DataFromCollectionSlug<S>, locale: string) => Promise<JsonLdOutput[]>;
|
|
257
|
+
};
|
|
258
|
+
declare function addCollectionsToSitemap(exports: Array<{
|
|
259
|
+
default: () => Promise<MetadataRoute.Sitemap>;
|
|
260
|
+
generateSitemap: () => Promise<MetadataRoute.Sitemap>;
|
|
261
|
+
}>): {
|
|
262
|
+
default: () => Promise<MetadataRoute.Sitemap>;
|
|
263
|
+
generateSitemap: () => Promise<MetadataRoute.Sitemap>;
|
|
264
|
+
};
|
|
265
|
+
declare const STATIC_PAGES_SLUG = "staticPages";
|
|
266
|
+
import { Block, CollectionConfig } from "payload";
|
|
267
|
+
import { CollectionAfterChangeHook, CollectionAfterDeleteHook } from "payload";
|
|
268
|
+
type LocalePrefixMode = "always" | "as-needed" | "never";
|
|
269
|
+
type CreateRevalidateCollectionHookOptions = {
|
|
270
|
+
/**
|
|
271
|
+
* The collection's slug. Used in the per-collection tag fired
|
|
272
|
+
* alongside path invalidation: `collection_<slug>_<id>`.
|
|
273
|
+
*/
|
|
274
|
+
collectionSlug: string;
|
|
275
|
+
/**
|
|
276
|
+
* URL path prefix for this collection's rendered URLs. Pages use
|
|
277
|
+
* `''` (mounted at root); Posts use `'/posts'`. Leading slash,
|
|
278
|
+
* no trailing slash — same convention as
|
|
279
|
+
* `createSitemapFile.urlPrefixes`.
|
|
280
|
+
*/
|
|
281
|
+
urlPathPrefix?: string;
|
|
282
|
+
/**
|
|
283
|
+
* Sitemap tag the collection's revalidation hook invalidates on
|
|
284
|
+
* every save. Defaults to `${collectionSlug}-sitemap`. Pass
|
|
285
|
+
* `false` to opt out (collections without a sitemap handler).
|
|
286
|
+
*/
|
|
287
|
+
sitemapTag?: string | false;
|
|
288
|
+
/**
|
|
289
|
+
* Locale prefix mode — mirrors next-intl's `localePrefix`.
|
|
290
|
+
* Defaults to `'always'` (preserves legacy behavior).
|
|
291
|
+
*/
|
|
292
|
+
localePrefix?: LocalePrefixMode;
|
|
293
|
+
/**
|
|
294
|
+
* Default locale for `localePrefix: 'as-needed'`. Falls back to
|
|
295
|
+
* `req.payload.config.localization.defaultLocale` at request time
|
|
296
|
+
* when omitted.
|
|
297
|
+
*/
|
|
298
|
+
defaultLocale?: string;
|
|
299
|
+
/**
|
|
300
|
+
* Path invalidation strategy. Default: `'url'` — fans out
|
|
301
|
+
* `revalidatePath` for every locale × every slug. Set to
|
|
302
|
+
* `'tag-only'` for collections without a URL (e.g. `staticPages`
|
|
303
|
+
* — addressed by a `kind` discriminator, not a slug). Tag-only
|
|
304
|
+
* mode still fires the per-collection tag (via `sitemapTag`) and
|
|
305
|
+
* the per-id tag (`collection_<slug>_<id>`).
|
|
306
|
+
*/
|
|
307
|
+
pathMode?: "url" | "tag-only";
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* Canonical factory for **all** collection revalidation hooks —
|
|
311
|
+
* Pages, Posts, and any host-defined collection.
|
|
312
|
+
*
|
|
313
|
+
* Behavior:
|
|
314
|
+
*
|
|
315
|
+
* - Fires `revalidatePath` for **every** locale the host has
|
|
316
|
+
* declared (not just the request locale). The path is
|
|
317
|
+
* `${prefixFor(locale)}${urlPathPrefix}/${slug}` (or
|
|
318
|
+
* `${prefixFor(locale)}${urlPathPrefix}` for the home page with
|
|
319
|
+
* empty slug).
|
|
320
|
+
* - Fires `revalidateTag(sitemapTag, 'max')` on every change /
|
|
321
|
+
* delete so the sitemap handler sees fresh data.
|
|
322
|
+
* - Fires `revalidateTag('collection_<slug>_<id>', 'max')` so
|
|
323
|
+
* hosts using `unstable_cache` keyed by id stay fresh.
|
|
324
|
+
* - Handles slug renames while published (fires both old and new
|
|
325
|
+
* paths across all locales).
|
|
326
|
+
* - Respects `req.context.disableRevalidate` for seed / test
|
|
327
|
+
* scripts.
|
|
328
|
+
*
|
|
329
|
+
* Use `createRevalidateCollectionHook({ ... })` for any
|
|
330
|
+
* collection. For Pages specifically, the lib still exposes
|
|
331
|
+
* `createRevalidatePageHooks()` as a deprecated alias that
|
|
332
|
+
* delegates to this factory with `collectionSlug: 'pages'` and
|
|
333
|
+
* `urlPathPrefix: ''`.
|
|
334
|
+
*/
|
|
335
|
+
declare function createRevalidateCollectionHook(options: CreateRevalidateCollectionHookOptions): {
|
|
336
|
+
afterChange: CollectionAfterChangeHook;
|
|
337
|
+
afterDelete: CollectionAfterDeleteHook;
|
|
338
|
+
};
|
|
339
|
+
type CreateRevalidatePageHooksOptions = Omit<CreateRevalidateCollectionHookOptions, "collectionSlug" | "urlPathPrefix">;
|
|
340
|
+
/**
|
|
341
|
+
* @deprecated Use `createRevalidateCollectionHook({ collectionSlug: 'pages', urlPathPrefix: '' })` instead.
|
|
342
|
+
* Kept so hosts that imported this name directly don't break — the
|
|
343
|
+
* alias delegates to the canonical factory with the Pages preset.
|
|
344
|
+
*/
|
|
345
|
+
declare const createRevalidatePageHooks: (opts?: CreateRevalidatePageHooksOptions) => {
|
|
346
|
+
afterChange: CollectionAfterChangeHook;
|
|
347
|
+
afterDelete: CollectionAfterDeleteHook;
|
|
348
|
+
};
|
|
349
|
+
declare const HOME_PAGE_SLUG = "";
|
|
350
|
+
declare const PAGES_SLUG = "pages";
|
|
351
|
+
type CreatePagesCollectionOptions = {
|
|
352
|
+
/**
|
|
353
|
+
* Blocks the Pages collection accepts.
|
|
354
|
+
*/
|
|
355
|
+
blocks: Block[];
|
|
356
|
+
/**
|
|
357
|
+
* Optional override for the collection slug. Default: `'pages'`.
|
|
358
|
+
* Hosts that want a different slug (e.g. `'site_pages'`) pass
|
|
359
|
+
* it here. The lib's Header / Footer `linkRelationTo` default
|
|
360
|
+
* uses `'pages'` — combine this with a matching
|
|
361
|
+
* `linkRelationTo` to keep nav links targeting the right
|
|
362
|
+
* collection.
|
|
363
|
+
*/
|
|
364
|
+
slug?: string;
|
|
365
|
+
/**
|
|
366
|
+
* Optional override for the `custom.path` Payload uses to resolve
|
|
367
|
+
* the page's render module. Default: the lib's `PAGES_RENDER_PATH`
|
|
368
|
+
* (a Server Component that calls `RenderBlocks`). Use this when
|
|
369
|
+
* you've defined your own Server Component for the collection.
|
|
370
|
+
*/
|
|
371
|
+
renderPath?: string;
|
|
372
|
+
/**
|
|
373
|
+
* Locale prefix mode for path invalidation. Defaults to `'always'`
|
|
374
|
+
* (preserves current behavior). Set to `'as-needed'` when the host
|
|
375
|
+
* uses next-intl `localePrefix: 'as-needed'` — otherwise the hook
|
|
376
|
+
* invalidates paths the public routes don't use.
|
|
377
|
+
*/
|
|
378
|
+
localePrefix?: CreateRevalidateCollectionHookOptions["localePrefix"];
|
|
379
|
+
/**
|
|
380
|
+
* Default locale for prefix skipping. Falls back to
|
|
381
|
+
* `req.payload.config.localization.defaultLocale` at request time
|
|
382
|
+
* when omitted.
|
|
383
|
+
*/
|
|
384
|
+
defaultLocale?: CreateRevalidateCollectionHookOptions["defaultLocale"];
|
|
385
|
+
};
|
|
386
|
+
declare const createPagesCollection: (blocks: Block[], options?: Omit<CreatePagesCollectionOptions, "blocks">) => CollectionConfig;
|
|
387
|
+
import { CollectionConfig as CollectionConfig2 } from "payload";
|
|
388
|
+
declare const POSTS_SLUG = "posts";
|
|
389
|
+
type CreatePostsCollectionOptions = {
|
|
390
|
+
/**
|
|
391
|
+
* Optional override for the collection slug. Default: `'posts'`.
|
|
392
|
+
* Hosts that want a different slug (e.g. `'articles'` or `'blog'`)
|
|
393
|
+
* pass it here. Combine with the page route's URL convention and
|
|
394
|
+
* the lib's translator plugin's `collections` list.
|
|
395
|
+
*/
|
|
396
|
+
slug?: string;
|
|
397
|
+
/**
|
|
398
|
+
* Override the `custom.path` Payload uses to resolve the post's
|
|
399
|
+
* render module. Defaults to the lib's `POSTS_RENDER_PATH`
|
|
400
|
+
* (the lib's `<PostsPage>` Server Component, which renders
|
|
401
|
+
* `title` + `excerpt` + Lexical `content`). Hosts that want a
|
|
402
|
+
* custom render pass their own Server Component's import path
|
|
403
|
+
* here (e.g. `'@/blog/Post#default'`).
|
|
404
|
+
*/
|
|
405
|
+
renderPath?: string;
|
|
406
|
+
/**
|
|
407
|
+
* Locale prefix mode for path invalidation. Defaults to `'always'`.
|
|
408
|
+
* Set to `'as-needed'` when the host uses next-intl
|
|
409
|
+
* `localePrefix: 'as-needed'` — otherwise the hook invalidates
|
|
410
|
+
* paths the public routes don't use.
|
|
411
|
+
*/
|
|
412
|
+
localePrefix?: "always" | "as-needed" | "never";
|
|
413
|
+
/**
|
|
414
|
+
* Default locale for prefix skipping. Falls back to
|
|
415
|
+
* `req.payload.config.localization.defaultLocale` at request time
|
|
416
|
+
* when omitted.
|
|
417
|
+
*/
|
|
418
|
+
defaultLocale?: string;
|
|
419
|
+
};
|
|
420
|
+
/**
|
|
421
|
+
* Build the Posts collection. Posts have a simpler shape than
|
|
422
|
+
* Pages: `title` + `excerpt` (both localized) + a Lexical `content`
|
|
423
|
+
* rich text field. Hosts that want blocks can either swap the
|
|
424
|
+
* `content` field for a `blocks` field via the returned config, or
|
|
425
|
+
* define a custom Post shape entirely.
|
|
426
|
+
*
|
|
427
|
+
* The Posts collection exists primarily so the lib's translator
|
|
428
|
+
* plugin has a second localized collection to translate.
|
|
429
|
+
*/
|
|
430
|
+
declare const createPostsCollection: (options?: CreatePostsCollectionOptions) => CollectionConfig2;
|
|
431
|
+
import { Block as Block2, CollectionConfig as CollectionConfig3 } from "payload";
|
|
432
|
+
type CreateStaticPagesCollectionOptions = {
|
|
433
|
+
/**
|
|
434
|
+
* Blocks the StaticPages collection accepts. Hosts pass the same
|
|
435
|
+
* `blocks` they use for `createPagesCollection` (or a smaller
|
|
436
|
+
* subset — e.g. just `pageHeroBlock` + `ctaBlock` + `featureGridBlock`).
|
|
437
|
+
* The lib does not curate a separate block set for system pages.
|
|
438
|
+
*/
|
|
439
|
+
blocks: Block2[];
|
|
440
|
+
};
|
|
441
|
+
declare const createStaticPagesCollection: (blocks: Block2[]) => CollectionConfig3;
|
|
442
|
+
import { GlobalConfig } from "payload";
|
|
443
|
+
type CreateHeaderGlobalOptions = {
|
|
444
|
+
/**
|
|
445
|
+
* Optional override for the `custom.path` Payload uses to resolve
|
|
446
|
+
* the header's render module. Default: the lib's `HEADER_RENDER_PATH`.
|
|
447
|
+
*/
|
|
448
|
+
renderPath?: string;
|
|
449
|
+
/**
|
|
450
|
+
* Collection slugs the nav's link fields can reference. Required
|
|
451
|
+
* by Payload 3.85 — empty `relationTo` arrays are rejected.
|
|
452
|
+
* Defaults to `['pages']` (the lib's Pages collection). Pass a
|
|
453
|
+
* different list when your host has additional linkable collections.
|
|
454
|
+
*/
|
|
455
|
+
linkRelationTo?: string[];
|
|
456
|
+
};
|
|
457
|
+
/**
|
|
458
|
+
* Build the Header global. The lib's default shape: a `nav` blocks
|
|
459
|
+
* field with two block types — `navColumn` (a titled group of links)
|
|
460
|
+
* and `navItem` (a single link).
|
|
461
|
+
*/
|
|
462
|
+
declare const createHeaderGlobal: (options?: CreateHeaderGlobalOptions) => GlobalConfig;
|
|
463
|
+
import { GlobalConfig as GlobalConfig2 } from "payload";
|
|
464
|
+
type CreateFooterGlobalOptions = {
|
|
465
|
+
/**
|
|
466
|
+
* Optional override for the `custom.path` Payload uses to resolve
|
|
467
|
+
* the footer's render module. Default: the lib's `FOOTER_RENDER_PATH`.
|
|
468
|
+
*/
|
|
469
|
+
renderPath?: string;
|
|
470
|
+
/**
|
|
471
|
+
* Collection slugs the nav's link fields can reference. Required
|
|
472
|
+
* by Payload 3.85 — empty `relationTo` arrays are rejected.
|
|
473
|
+
* Defaults to `['pages']` (the lib's Pages collection). Pass a
|
|
474
|
+
* different list when your host has additional linkable collections.
|
|
475
|
+
*/
|
|
476
|
+
linkRelationTo?: string[];
|
|
477
|
+
};
|
|
478
|
+
/**
|
|
479
|
+
* Build the Footer global. The lib's default shape mirrors the
|
|
480
|
+
* Header: a `nav` blocks field with `navColumn` (a titled group of
|
|
481
|
+
* links) and `navItem` (a single link) blocks.
|
|
482
|
+
*/
|
|
483
|
+
declare const createFooterGlobal: (options?: CreateFooterGlobalOptions) => GlobalConfig2;
|
|
484
|
+
type WWWConfigOptions = {
|
|
485
|
+
/**
|
|
486
|
+
* Locales the host uses. First entry is the default locale
|
|
487
|
+
* (used for translation source-of-truth and the home-page path).
|
|
488
|
+
* The list drives hreflang alternates, sitemap, and the per-locale
|
|
489
|
+
* revalidation tag suffix.
|
|
490
|
+
*/
|
|
491
|
+
locales: string[];
|
|
492
|
+
/**
|
|
493
|
+
* The host's next-intl routing config (the value returned from
|
|
494
|
+
* `defineRouting({...})`). When passed, `locales`, `defaultLocale`,
|
|
495
|
+
* and `localePrefix` are read from this object instead of the
|
|
496
|
+
* legacy `locales: string[]` field. `localePrefix` is normalized
|
|
497
|
+
* to the simple string form internally — next-intl's verbose
|
|
498
|
+
* `{ mode, prefixes? }` shape is accepted and reduced to `mode`.
|
|
499
|
+
*/
|
|
500
|
+
routing?: PageRouting;
|
|
501
|
+
/**
|
|
502
|
+
* Blocks the Pages collection accepts.
|
|
503
|
+
*/
|
|
504
|
+
blocks: Block3[];
|
|
505
|
+
/**
|
|
506
|
+
* Collection slugs the Header / Footer nav `link` fields can
|
|
507
|
+
* reference. Defaults to `['pages']` (the lib's Pages collection).
|
|
508
|
+
* Pass a different list when your host has additional linkable
|
|
509
|
+
* collections.
|
|
510
|
+
*/
|
|
511
|
+
linkRelationTo?: string[];
|
|
512
|
+
/**
|
|
513
|
+
* Register the lib's Posts collection. Default: `true`. The
|
|
514
|
+
* translator plugin's default `collections` list is
|
|
515
|
+
* `['pages', 'posts']`; pass `false` here to opt out and either
|
|
516
|
+
* define your own posts-like collection or drop the translator.
|
|
517
|
+
*/
|
|
518
|
+
registerPosts?: boolean;
|
|
519
|
+
/**
|
|
520
|
+
* Final say on the lib's default plugin list. Receives the
|
|
521
|
+
* `[seoPlugin, imageHashPlugin, translator]` array; return the
|
|
522
|
+
* list to apply. Common uses: drop the translator (no AI
|
|
523
|
+
* translation in this project), add a second `seoPlugin({...})`
|
|
524
|
+
* call for posts, or layer on a `formBuilderPlugin(...)`.
|
|
525
|
+
*/
|
|
526
|
+
defaultPlugins?: (defaults: Plugin[]) => Plugin[];
|
|
527
|
+
};
|
|
528
|
+
type WWWConfigApi = {
|
|
529
|
+
withWWWConfig: (config: WWWInputConfig) => Promise<Config> | Config;
|
|
530
|
+
};
|
|
531
|
+
type WWWInputConfig = Omit<Config, "collections" | "globals"> & {
|
|
532
|
+
collections: ((args: {
|
|
533
|
+
defaultCollections: CollectionConfig4[];
|
|
534
|
+
}) => CollectionConfig4[]) | CollectionConfig4[];
|
|
535
|
+
globals: ((args: {
|
|
536
|
+
defaultGlobals: GlobalConfig3[];
|
|
537
|
+
}) => GlobalConfig3[]) | GlobalConfig3[];
|
|
538
|
+
};
|
|
539
|
+
/**
|
|
540
|
+
* Build the lib's data-config API surface, configured for a specific host.
|
|
541
|
+
*
|
|
542
|
+
* Hosts call this once with their `locales` and `blocks`; the returned
|
|
543
|
+
* object is **safe to import from a Node entrypoint** such as
|
|
544
|
+
* `payload.config.ts` — it only contains Payload collection / global
|
|
545
|
+
* factories and the `withWWWConfig` composer.
|
|
546
|
+
*
|
|
547
|
+
* The lib applies three plugins by default: `seoPlugin` (Pages + meta tab),
|
|
548
|
+
* `imageHashPlugin` (Blurhash/Thumbhash on uploads), and `translator`
|
|
549
|
+
* (auto-translation workflow). Use the `defaultPlugins` callback to
|
|
550
|
+
* drop or extend the list.
|
|
551
|
+
*
|
|
552
|
+
* For the App Router rendering side, import from the lib's render
|
|
553
|
+
* subpaths:
|
|
554
|
+
*
|
|
555
|
+
* import { createCollectionPageExports } from '@justanarthur/payload-www/render-pages'
|
|
556
|
+
* import { createPreviewHandler, createSitemapFile } from '@justanarthur/payload-www/render-utils'
|
|
557
|
+
*/
|
|
558
|
+
declare function createWWWConfig(options: WWWConfigOptions): WWWConfigApi;
|
|
559
|
+
import { Access } from "payload";
|
|
560
|
+
declare const anyone: Access;
|
|
561
|
+
declare const authenticated: Access;
|
|
562
|
+
declare const authenticatedOrPublished: Access;
|
|
563
|
+
import { GlobalAfterChangeHook } from "payload";
|
|
564
|
+
/**
|
|
565
|
+
* Build a tag-based revalidation hook for a global. Fires two tags
|
|
566
|
+
* after a save:
|
|
567
|
+
*
|
|
568
|
+
* - `global_${slug}` — invalidates the lib's `getCachedGlobal` cache
|
|
569
|
+
* and any host caches that key by slug alone.
|
|
570
|
+
* - `global_${slug}_${locale}` — invalidates per-locale cache slots
|
|
571
|
+
* for hosts that key by `[slug, locale]`.
|
|
572
|
+
*
|
|
573
|
+
* The hook fires both so the lib's single-slot cache and the
|
|
574
|
+
* per-locale pattern both stay fresh regardless of which the host
|
|
575
|
+
* uses.
|
|
576
|
+
*/
|
|
577
|
+
declare function createRevalidateGlobalHook(slug: string): GlobalAfterChangeHook;
|
|
578
|
+
import { Field, GroupField } from "payload";
|
|
579
|
+
type LinkAppearances = "default" | "outline";
|
|
580
|
+
declare const appearanceOptions: Record<LinkAppearances, {
|
|
581
|
+
label: string;
|
|
582
|
+
value: string;
|
|
583
|
+
}>;
|
|
584
|
+
type LinkOptions = {
|
|
585
|
+
appearances?: LinkAppearances[] | false;
|
|
586
|
+
disableLabel?: boolean;
|
|
587
|
+
/**
|
|
588
|
+
* Collection slugs the link can reference. Payload 3.85 rejects
|
|
589
|
+
* empty arrays, so the lib defaults to `['pages']` (its own Pages
|
|
590
|
+
* collection). Hosts that reference different collections pass
|
|
591
|
+
* their own list.
|
|
592
|
+
*/
|
|
593
|
+
relationTo?: string[];
|
|
594
|
+
/** Mark the text fields as `localized: true`. */
|
|
595
|
+
localized?: boolean;
|
|
596
|
+
/** Deep-merge into the resulting group. */
|
|
597
|
+
overrides?: Partial<GroupField>;
|
|
598
|
+
/** Legacy alias for the host's custom field overrides. */
|
|
599
|
+
linkOverrides?: Partial<GroupField>;
|
|
600
|
+
};
|
|
601
|
+
declare const link: (options?: LinkOptions) => Field;
|
|
602
|
+
import { Field as Field2 } from "payload";
|
|
603
|
+
declare const linkGroup: (options?: LinkOptions) => Field2;
|
|
604
|
+
import { ImportMap as ImportMap2 } from "payload";
|
|
605
|
+
declare function getFromImportMap(key: string, importMap: ImportMap2): any;
|
|
606
|
+
declare function generateImportName(type: "block" | "page", slug: string): string;
|
|
607
|
+
import { ImportMap as ImportMap3 } from "payload";
|
|
608
|
+
import { JSX as JSX_1kxb } from "react/jsx-runtime";
|
|
609
|
+
type Element_12xgc = JSX_1kxb["Element"];
|
|
610
|
+
declare function renderCollectionModule(collection: {
|
|
611
|
+
slug: string;
|
|
612
|
+
custom?: Record<string, any>;
|
|
613
|
+
}[] | undefined, slug: string, importMap: ImportMap3, props?: Record<string, any>): Element_12xgc | null;
|
|
614
|
+
import { ImportMap as ImportMap4 } from "payload";
|
|
615
|
+
import { JSX as JSX_1kxb2 } from "react/jsx-runtime";
|
|
616
|
+
type Element_12xgc2 = JSX_1kxb2["Element"];
|
|
617
|
+
/**
|
|
618
|
+
* Mirror of `renderCollectionModule` for Payload globals. Reads
|
|
619
|
+
* `global.custom.path`, resolves it through the importMap, and renders
|
|
620
|
+
* the resulting module with the supplied props.
|
|
621
|
+
*
|
|
622
|
+
* Globals don't have a `slug` field on docs (they're singletons), so
|
|
623
|
+
* the only meaningful input beyond `importMap` is the resolved data
|
|
624
|
+
* and the active locale.
|
|
625
|
+
*
|
|
626
|
+
* Returns `null` when:
|
|
627
|
+
* - the global isn't registered in the host's Payload config
|
|
628
|
+
* (`globals.find(...)` returns undefined)
|
|
629
|
+
* - `custom.path` is missing on the global
|
|
630
|
+
* - the importMap doesn't have an entry for that path
|
|
631
|
+
*
|
|
632
|
+
* Throws in dev when `custom.path` is set but the importMap is
|
|
633
|
+
* missing the entry — matches `renderCollectionModule`'s strictness
|
|
634
|
+
* so the host gets a clear error in the console instead of a silent
|
|
635
|
+
* layout break.
|
|
636
|
+
*/
|
|
637
|
+
declare function renderGlobalModule(globals: {
|
|
638
|
+
slug: string;
|
|
639
|
+
custom?: Record<string, any>;
|
|
640
|
+
}[] | undefined, slug: string, importMap: ImportMap4, props?: Record<string, any>): Element_12xgc2 | null;
|
|
641
|
+
import { DataFromGlobalSlug, SanitizedConfig as SanitizedConfig2 } from "payload";
|
|
642
|
+
/**
|
|
643
|
+
* Build an `unstable_cache`-wrapped getter for a Payload global.
|
|
644
|
+
* Tag is `global_<slug>` (covers all locales); the lib's
|
|
645
|
+
* `createRevalidateGlobalHook` fires both this tag and a per-locale
|
|
646
|
+
* `global_<slug>_<locale>` so both single-slot and per-locale cache
|
|
647
|
+
* strategies stay fresh after a save.
|
|
648
|
+
*
|
|
649
|
+
* Hosts that already had a hand-rolled `getCachedGlobal` (e.g. the
|
|
650
|
+
* demo) can swap their import for this one without changing the
|
|
651
|
+
* call sites — the shape matches.
|
|
652
|
+
*
|
|
653
|
+
* Usage:
|
|
654
|
+
*
|
|
655
|
+
* import { getCachedGlobal } from '@justanarthur/payload-www/server'
|
|
656
|
+
* const header = await getCachedGlobal(configPromise, 'header', 1)()
|
|
657
|
+
*/
|
|
658
|
+
declare const getCachedGlobal: <G extends string>(config: Promise<SanitizedConfig2>, slug: G, depth?: number) => (() => Promise<DataFromGlobalSlug<G> | null>);
|
|
659
|
+
/**
|
|
660
|
+
* Type alias for the return shape — matches Payload's
|
|
661
|
+
* `DataFromGlobalSlug<slug>` for typed access in the host.
|
|
662
|
+
*/
|
|
663
|
+
type CachedGlobal<G extends string> = DataFromGlobalSlug<G>;
|
|
664
|
+
declare function buildHreflangAlternates<L extends string>({ siteUrl, locale, urlPrefix, storedSlug, queryAllLocaleSlugs, nested, homeSlug, defaultLocale, locales, localePrefix }: {
|
|
665
|
+
siteUrl: string;
|
|
666
|
+
locale: L;
|
|
667
|
+
urlPrefix: string;
|
|
668
|
+
storedSlug: string;
|
|
669
|
+
queryAllLocaleSlugs: (slug: string, locale: L) => Promise<Partial<Record<L, string>> | undefined>;
|
|
670
|
+
nested: boolean;
|
|
671
|
+
homeSlug: string;
|
|
672
|
+
defaultLocale: L;
|
|
673
|
+
locales: readonly L[];
|
|
674
|
+
/**
|
|
675
|
+
* Locale prefix mode — mirrors next-intl's `localePrefix` so each
|
|
676
|
+
* alternate URL matches the host's actual route shape:
|
|
677
|
+
*
|
|
678
|
+
* - `'always'`: every URL is prefixed with `/{locale}/…`
|
|
679
|
+
* (e.g. `/en/about`, `/uk/about`). The default — preserves
|
|
680
|
+
* the helper's prior behavior.
|
|
681
|
+
* - `'as-needed'`: the default locale renders without a prefix
|
|
682
|
+
* (e.g. `/about`), other locales are prefixed (`/uk/about`).
|
|
683
|
+
* Critical: callers that emit hreflang alongside a canonical
|
|
684
|
+
* URL built with `as-needed` mode MUST pass this through,
|
|
685
|
+
* otherwise the `en` and `x-default` alternates point to URLs
|
|
686
|
+
* the host doesn't actually serve.
|
|
687
|
+
* - `'never'`: no locale prefix at all.
|
|
688
|
+
*/
|
|
689
|
+
localePrefix?: "always" | "as-needed" | "never";
|
|
690
|
+
}): Promise<Record<string, string>>;
|
|
691
|
+
declare function segmentsToStoredSlug(segments: string[] | string, nested?: boolean): string;
|
|
692
|
+
declare function segmentsToUrlPath(segments: string[] | string, nested?: boolean): string;
|
|
693
|
+
declare function storedSlugToSegments(storedSlug: string, nested?: boolean): string[] | string;
|
|
694
|
+
declare function buildCanonicalUrl<L extends string>({ siteUrl, locale, urlPrefix, urlPath }: {
|
|
695
|
+
siteUrl: string;
|
|
696
|
+
locale: L;
|
|
697
|
+
urlPrefix: string;
|
|
698
|
+
urlPath: string;
|
|
699
|
+
}): string;
|
|
700
|
+
declare function getUrlPath(segments: string[] | string, nested: boolean, homeSlug: string): string;
|
|
701
|
+
import { DataFromCollectionSlug as DataFromCollectionSlug2, DataFromGlobalSlug as DataFromGlobalSlug2, ImportMap as ImportMap5, SanitizedConfig as SanitizedConfig3 } from "payload";
|
|
702
|
+
declare const queryDocBySlug: <S extends string>({ collectionSlug, slug, slugField, locale, draft, config }: {
|
|
703
|
+
collectionSlug: S;
|
|
704
|
+
slug: string;
|
|
705
|
+
slugField?: string;
|
|
706
|
+
locale: string;
|
|
707
|
+
draft?: boolean;
|
|
708
|
+
config: Promise<SanitizedConfig3>;
|
|
709
|
+
}) => Promise<DataFromCollectionSlug2<S> | null>;
|
|
710
|
+
declare const queryAllDocs: <S extends string>({ collectionSlug, slugField, locale, config }: {
|
|
711
|
+
collectionSlug: S;
|
|
712
|
+
slugField?: string;
|
|
713
|
+
locale: string;
|
|
714
|
+
config: Promise<SanitizedConfig3>;
|
|
715
|
+
}) => Promise<DataFromCollectionSlug2<S>[]>;
|
|
716
|
+
declare const queryAllLocaleSlugs2: <S extends string>({ collectionSlug, slug, slugField, locale, config }: {
|
|
717
|
+
collectionSlug: S;
|
|
718
|
+
slug: string;
|
|
719
|
+
slugField?: string;
|
|
720
|
+
locale: string;
|
|
721
|
+
config: Promise<SanitizedConfig3>;
|
|
722
|
+
}) => Promise<Record<string, string> | undefined>;
|
|
723
|
+
declare const queryGlobal: <G extends string>({ globalSlug, locale, depth, draft, config }: {
|
|
724
|
+
globalSlug: G;
|
|
725
|
+
locale: string;
|
|
726
|
+
depth?: number;
|
|
727
|
+
draft?: boolean;
|
|
728
|
+
config: Promise<SanitizedConfig3>;
|
|
729
|
+
}) => Promise<DataFromGlobalSlug2<G> | null>;
|
|
730
|
+
declare function getRenderModuleExports(exportName: string, collection: {
|
|
731
|
+
custom?: Record<string, unknown>;
|
|
732
|
+
} | undefined, importMap: ImportMap5): unknown;
|
|
733
|
+
import { FC } from "react";
|
|
734
|
+
import { ImportMap as ImportMap6, SanitizedConfig as SanitizedConfig4 } from "payload";
|
|
735
|
+
type RenderBlocksProps = {
|
|
736
|
+
blocks: Array<{
|
|
737
|
+
blockType: string;
|
|
738
|
+
} & Record<string, unknown>>;
|
|
739
|
+
blockProps?: Record<string, unknown>;
|
|
740
|
+
importMap: ImportMap6;
|
|
741
|
+
config: SanitizedConfig4;
|
|
742
|
+
locale: string;
|
|
743
|
+
searchParams?: Record<string, string | string[] | undefined>;
|
|
744
|
+
};
|
|
745
|
+
/**
|
|
746
|
+
* Render a page's `blocks` array to React. Each block's render module
|
|
747
|
+
* is resolved via Payload's generated importMap. The host registers
|
|
748
|
+
* each block in the importMap with a key like `BlockCta#default` (use
|
|
749
|
+
* `generateImportName('block', 'cta')` to build the key).
|
|
750
|
+
*
|
|
751
|
+
* Falls back gracefully: if a block's importMap path is missing or
|
|
752
|
+
* the component is not registered, the block is skipped and a
|
|
753
|
+
* `console.warn` is logged (in dev).
|
|
754
|
+
*/
|
|
755
|
+
declare const RenderBlocks: FC<RenderBlocksProps>;
|
|
756
|
+
import { Payload } from "payload";
|
|
757
|
+
type SeedPageInput = {
|
|
758
|
+
slug: string;
|
|
759
|
+
title: Record<string, string>;
|
|
760
|
+
meta?: Record<string, {
|
|
761
|
+
title?: string;
|
|
762
|
+
description?: string;
|
|
763
|
+
}>;
|
|
764
|
+
blocks?: Array<Record<string, unknown>>;
|
|
765
|
+
status?: "draft" | "published";
|
|
766
|
+
publishedAt?: string;
|
|
767
|
+
};
|
|
768
|
+
type SeedPostInput = {
|
|
769
|
+
slug: string;
|
|
770
|
+
title: Record<string, string>;
|
|
771
|
+
excerpt?: Record<string, string>;
|
|
772
|
+
content?: Record<string, unknown>;
|
|
773
|
+
status?: "draft" | "published";
|
|
774
|
+
publishedAt?: string;
|
|
775
|
+
};
|
|
776
|
+
type SeedUserInput = {
|
|
777
|
+
email: string;
|
|
778
|
+
password?: string;
|
|
779
|
+
name?: string;
|
|
780
|
+
};
|
|
781
|
+
type SeedCategoryInput = {
|
|
782
|
+
title: string;
|
|
783
|
+
slug?: string;
|
|
784
|
+
};
|
|
785
|
+
type CreateBaseSeedOptions = {
|
|
786
|
+
defaultLocale?: string;
|
|
787
|
+
locales?: string[];
|
|
788
|
+
users?: SeedUserInput[];
|
|
789
|
+
categories?: SeedCategoryInput[];
|
|
790
|
+
pages?: SeedPageInput[];
|
|
791
|
+
posts?: SeedPostInput[];
|
|
792
|
+
dryRun?: boolean;
|
|
793
|
+
};
|
|
794
|
+
type CreateBaseSeedResult = {
|
|
795
|
+
users: Array<{
|
|
796
|
+
id: string | number;
|
|
797
|
+
email: string;
|
|
798
|
+
}>;
|
|
799
|
+
categories: Array<{
|
|
800
|
+
id: string | number;
|
|
801
|
+
title: string;
|
|
802
|
+
slug: string;
|
|
803
|
+
}>;
|
|
804
|
+
pages: Array<{
|
|
805
|
+
id: string | number;
|
|
806
|
+
slug: string;
|
|
807
|
+
locale: string;
|
|
808
|
+
}>;
|
|
809
|
+
posts: Array<{
|
|
810
|
+
id: string | number;
|
|
811
|
+
slug: string;
|
|
812
|
+
locale: string;
|
|
813
|
+
}>;
|
|
814
|
+
};
|
|
815
|
+
/**
|
|
816
|
+
* Idempotent seeder for the lib's collections. Re-running on the
|
|
817
|
+
* same database is a no-op for users (matched by email) and
|
|
818
|
+
* categories (matched by title); pages and posts are matched by
|
|
819
|
+
* slug and re-created if missing.
|
|
820
|
+
*
|
|
821
|
+
* Pages and posts are created once per slug — localized values are
|
|
822
|
+
* stored in a single doc per slug. Tests assert the alternate
|
|
823
|
+
* resolution by querying `locale: 'all'`.
|
|
824
|
+
*
|
|
825
|
+
* Throws on:
|
|
826
|
+
* - any block slug in a Page's `layout` that doesn't exist on the
|
|
827
|
+
* Pages collection's `blocks` field
|
|
828
|
+
* - a block without a `blockType`
|
|
829
|
+
*/
|
|
830
|
+
declare function createBaseSeed(payload: Payload, options?: CreateBaseSeedOptions): Promise<CreateBaseSeedResult>;
|
|
831
|
+
import { Payload as Payload2 } from "payload";
|
|
832
|
+
type CreateTestPayloadOptions = {
|
|
833
|
+
/** Default blocks for the Pages collection. */
|
|
834
|
+
blocks?: any[];
|
|
835
|
+
/** Locale list. First entry is the default locale. */
|
|
836
|
+
locales?: readonly string[];
|
|
837
|
+
/** Database file path. Default: temp file. */
|
|
838
|
+
databaseFile?: string;
|
|
839
|
+
/** Run payload auto-migration before returning. Default: `true`. */
|
|
840
|
+
migrate?: boolean;
|
|
841
|
+
/**
|
|
842
|
+
* Strip `versions` from the Pages collection. Default: `false`.
|
|
843
|
+
* Set to `true` for integration tests that don't need versioning
|
|
844
|
+
* (avoids a payload@3.85 drizzle version-table build quirk).
|
|
845
|
+
*/
|
|
846
|
+
overridePagesVersions?: boolean;
|
|
847
|
+
};
|
|
848
|
+
type CreateTestPayloadResult = {
|
|
849
|
+
payload: Payload2;
|
|
850
|
+
databaseFile: string;
|
|
851
|
+
destroy: () => Promise<void>;
|
|
852
|
+
};
|
|
853
|
+
/**
|
|
854
|
+
* Build a Payload instance backed by a temp SQLite database for
|
|
855
|
+
* vitest integration tests. The lib's `createWWWConfig` is wired
|
|
856
|
+
* with a single empty-block Pages collection; tests add more
|
|
857
|
+
* collections via `configOverrides` if needed.
|
|
858
|
+
*/
|
|
859
|
+
declare function createTestPayload(options?: CreateTestPayloadOptions): Promise<CreateTestPayloadResult>;
|
|
860
|
+
import { ImportMap as ImportMap7, SanitizedConfig as SanitizedConfig5 } from "payload";
|
|
861
|
+
import { ReactElement as ReactElement2 } from "react";
|
|
862
|
+
type CreateStaticPageExportsArgs = {
|
|
863
|
+
/**
|
|
864
|
+
* The `kind` discriminator to fetch from the `staticPages`
|
|
865
|
+
* collection. Default: `'not-found'`. The factory fetches the
|
|
866
|
+
* row where `kind === {kind}` and renders its `blocks` via
|
|
867
|
+
* `PagesPage` (the same component the catch-all dynamic route
|
|
868
|
+
* uses).
|
|
869
|
+
*/
|
|
870
|
+
kind?: string;
|
|
871
|
+
/**
|
|
872
|
+
* Payload config promise (same shape as `createCollectionPageExports`).
|
|
873
|
+
*/
|
|
874
|
+
config: Promise<SanitizedConfig5>;
|
|
875
|
+
/**
|
|
876
|
+
* Host's Payload importMap. Same purpose as the Pages factory.
|
|
877
|
+
* Default: `{}`.
|
|
878
|
+
*/
|
|
879
|
+
importMap?: ImportMap7;
|
|
880
|
+
};
|
|
881
|
+
/**
|
|
882
|
+
* Build a static page's default — designed for Next.js
|
|
883
|
+
* `not-found.tsx` / `error.tsx` (and similar) route files. Static
|
|
884
|
+
* pages are addressed by a `kind` discriminator, not a slug, so
|
|
885
|
+
* they don't need metadata, sitemap, or static-params plumbing.
|
|
886
|
+
*
|
|
887
|
+
* Per Next.js docs, not-found/error components receive **no
|
|
888
|
+
* props**. The active locale is read via `getLocale()` from
|
|
889
|
+
* `next-intl/server`, which reads from the request config
|
|
890
|
+
* populated by middleware from the `[locale]` URL segment (the
|
|
891
|
+
* host's `i18n/request.ts` handles invalid-locale fallback
|
|
892
|
+
* before this returns).
|
|
893
|
+
*
|
|
894
|
+
* // app/(frontend)/[locale]/not-found.tsx
|
|
895
|
+
* import configPromise from '@payload-config'
|
|
896
|
+
* import { createStaticPageExports } from '@justanarthur/payload-www/render-pages'
|
|
897
|
+
* import { importMap } from '@/app/(payload)/admin/importMap.js'
|
|
898
|
+
*
|
|
899
|
+
* const { default: NotFound } = createStaticPageExports({
|
|
900
|
+
* config: configPromise,
|
|
901
|
+
* importMap,
|
|
902
|
+
* })
|
|
903
|
+
* NotFound
|
|
904
|
+
*
|
|
905
|
+
* // app/(frontend)/[locale]/server-error.tsx
|
|
906
|
+
* const { default: ServerError } = createStaticPageExports({
|
|
907
|
+
* kind: 'server-error',
|
|
908
|
+
* config: configPromise,
|
|
909
|
+
* importMap,
|
|
910
|
+
* })
|
|
911
|
+
* ServerError
|
|
912
|
+
*/
|
|
913
|
+
declare function createStaticPageExports({ kind, config: configPromise, importMap: importMapArg }: CreateStaticPageExportsArgs): {
|
|
914
|
+
default: () => Promise<ReactElement2>;
|
|
915
|
+
};
|
|
916
|
+
import { CollectionSlug, PayloadRequest } from "payload";
|
|
917
|
+
declare function generatePreviewPath({ collection, slug }: {
|
|
918
|
+
collection: CollectionSlug;
|
|
919
|
+
slug: string | null | undefined;
|
|
920
|
+
req?: PayloadRequest;
|
|
921
|
+
}): string | null;
|
|
922
|
+
export { storedSlugToSegments, segmentsToUrlPath, segmentsToStoredSlug, renderGlobalModule, renderCollectionModule, queryGlobal, queryDocBySlug, queryAllLocaleSlugs2 as queryAllLocaleSlugs, queryAllDocs, linkGroup, link, getUrlPath, getRenderModuleExports, getFromImportMap, getCachedGlobal, generatePreviewPath, generateImportName, createWWWConfig as default, createWWWConfig, createTestPayload, createStaticPagesCollection, createStaticPageExports, createRevalidatePageHooks, createRevalidateGlobalHook, createRevalidateCollectionHook, createPostsCollection, createPagesCollection, createHeaderGlobal, createFooterGlobal, createCollectionPageExports, createBaseSeed, buildOrganizationLd, buildHreflangAlternates, buildCanonicalUrl, buildBreadcrumbsLd, buildArticleLd, authenticatedOrPublished, authenticated, appearanceOptions, anyone, addCollectionsToSitemap, WWWInputConfig, WWWConfigOptions, WWWConfigApi, SeedUserInput, SeedPostInput, SeedPageInput, SeedCategoryInput, STATIC_PAGES_SLUG, RenderBlocksProps, RenderBlocks, PageExtendProps, POSTS_SLUG, PAGES_SLUG, MetadataOptions, LinkOptions, LinkAppearances, JsonLdOutput, JsonLdEntry, HOME_PAGE_SLUG, CreateTestPayloadResult, CreateTestPayloadOptions, CreateStaticPagesCollectionOptions, CreateStaticPageExportsArgs, CreateRevalidatePageHooksOptions, CreateRevalidateCollectionHookOptions, CreatePostsCollectionOptions, CreatePagesCollectionOptions, CreateHeaderGlobalOptions, CreateFooterGlobalOptions, CreateCollectionPageExportsDeps, CreateCollectionPageExportsArgs, CreateBaseSeedResult, CreateBaseSeedOptions, CachedGlobal, BreadcrumbItem, ArticleLdOptions };
|