@justanarthur/payload-www 0.3.5 → 1.2.0

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