@justanarthur/payload-www 2.2.8 → 2.2.9

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 CHANGED
@@ -144,6 +144,7 @@ const { default: PostPage, generateMetadata, generateStaticParams } = createColl
144
144
  | `routing` | `RoutingConfig` | required | `{ locales, defaultLocale, localePrefix, labels? }` from `next-intl/routing`'s `defineRouting` |
145
145
  | `slug` | `string` | `'pages'` | collection slug to query |
146
146
  | `slugShape` | `'single' \| 'catch-all'` | `'single'` | drives `generateStaticParams` + slug segmentation |
147
+ | `depth` | `number` | `2` | relationship / upload hops populated on the rendered document. `0` hands every media and relationship field to the render component as a bare id. Enumeration (`generateStaticParams`, `generateSitemap`) stays at `0` regardless. |
147
148
 
148
149
  ### `createCollectionPageExports(args, deps)` — deps
149
150
 
@@ -171,6 +172,7 @@ const { default: PostPage, generateMetadata, generateStaticParams } = createColl
171
172
  | `config` | `Promise<SanitizedConfig>` | required |
172
173
  | `importMap` | `ImportMap` | required |
173
174
  | `routing` | `RoutingConfig` | required |
175
+ | `depth` | `number` | relationship / upload hops populated on the `header` + `footer` globals. Defaults to `2`. |
174
176
 
175
177
  | dep | type | notes |
176
178
  |---|---|---|
@@ -20,6 +20,7 @@ type QueryDocArgs = ({
20
20
  globalSlug: string;
21
21
  locale: string;
22
22
  draft?: boolean;
23
+ depth?: number;
23
24
  }) | ({
24
25
  collectionSlug: string;
25
26
  slug: string;
@@ -132,6 +132,7 @@ async function requireCacheHelpers() {
132
132
  }
133
133
  throw new Error("[payload-www] seedPayloadCache({ config }) must be called before any query getter. " + "Call it from createCollectionPageExports / createRootLayoutExports factory, or in your root layout.");
134
134
  }
135
+ var RENDER_DEPTH = 2;
135
136
  async function queryDocBySlug(args) {
136
137
  "use cache";
137
138
  cacheLife("weeks");
@@ -142,7 +143,7 @@ async function queryDocBySlug(args) {
142
143
  locale: args.locale,
143
144
  draft: args.draft ?? false,
144
145
  overrideAccess: args.draft ?? false,
145
- depth: args.depth
146
+ depth: args.depth ?? RENDER_DEPTH
146
147
  });
147
148
  const result = await find(args.slug);
148
149
  const doc = result ?? (isIndexSlug(args.slug) ? await find(null) : null);
@@ -156,7 +157,7 @@ async function queryGlobal(args) {
156
157
  const result = await findGlobal(args.globalSlug, {
157
158
  locale: args.locale,
158
159
  draft: args.draft ?? false,
159
- depth: args.depth
160
+ depth: args.depth ?? RENDER_DEPTH
160
161
  });
161
162
  return result ?? null;
162
163
  } catch (error) {
@@ -172,7 +173,7 @@ async function queryAllDocs(args) {
172
173
  const { ids } = await findIds(collection, { locale: args.locale, pagination: false, overrideAccess: false });
173
174
  if (ids.length === 0)
174
175
  return [];
175
- const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false })));
176
+ const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false, depth: 0 })));
176
177
  return docs.filter((d) => d !== null);
177
178
  }
178
179
  async function queryDoc(args) {
@@ -199,7 +200,7 @@ async function queryDocByID(args) {
199
200
  locale: args.locale,
200
201
  draft: args.draft ?? false,
201
202
  overrideAccess: args.draft ?? false,
202
- depth: args.depth
203
+ depth: args.depth ?? RENDER_DEPTH
203
204
  });
204
205
  }
205
206
 
package/dist/metadata.js CHANGED
@@ -140,6 +140,7 @@ async function requireCacheHelpers() {
140
140
  }
141
141
  throw new Error("[payload-www] seedPayloadCache({ config }) must be called before any query getter. " + "Call it from createCollectionPageExports / createRootLayoutExports factory, or in your root layout.");
142
142
  }
143
+ var RENDER_DEPTH = 2;
143
144
  async function queryDocBySlug(args) {
144
145
  "use cache";
145
146
  cacheLife("weeks");
@@ -150,7 +151,7 @@ async function queryDocBySlug(args) {
150
151
  locale: args.locale,
151
152
  draft: args.draft ?? false,
152
153
  overrideAccess: args.draft ?? false,
153
- depth: args.depth
154
+ depth: args.depth ?? RENDER_DEPTH
154
155
  });
155
156
  const result = await find(args.slug);
156
157
  const doc = result ?? (isIndexSlug(args.slug) ? await find(null) : null);
@@ -164,7 +165,7 @@ async function queryGlobal(args) {
164
165
  const result = await findGlobal(args.globalSlug, {
165
166
  locale: args.locale,
166
167
  draft: args.draft ?? false,
167
- depth: args.depth
168
+ depth: args.depth ?? RENDER_DEPTH
168
169
  });
169
170
  return result ?? null;
170
171
  } catch (error) {
@@ -180,7 +181,7 @@ async function queryAllDocs(args) {
180
181
  const { ids } = await findIds(collection, { locale: args.locale, pagination: false, overrideAccess: false });
181
182
  if (ids.length === 0)
182
183
  return [];
183
- const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false })));
184
+ const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false, depth: 0 })));
184
185
  return docs.filter((d) => d !== null);
185
186
  }
186
187
  async function queryDoc(args) {
@@ -207,7 +208,7 @@ async function queryDocByID(args) {
207
208
  locale: args.locale,
208
209
  draft: args.draft ?? false,
209
210
  overrideAccess: args.draft ?? false,
210
- depth: args.depth
211
+ depth: args.depth ?? RENDER_DEPTH
211
212
  });
212
213
  }
213
214
 
package/dist/pages.d.ts CHANGED
@@ -39,6 +39,8 @@ type CreateCollectionPageExportsArgs<S extends string = "pages"> = {
39
39
  importMap: ImportMap3;
40
40
  routing: RoutingConfig;
41
41
  slugShape?: SlugShape;
42
+ /** Relationship / upload hops populated on the rendered document. `0` renders them as bare ids. */
43
+ depth?: number;
42
44
  };
43
45
  type CreateCollectionPageExportsDeps<S extends string> = {
44
46
  getServerSideURL: () => string;
@@ -46,7 +48,7 @@ type CreateCollectionPageExportsDeps<S extends string> = {
46
48
  /** Rendered while the document streams. Defaults to nothing. */
47
49
  fallback?: ReactNode2;
48
50
  };
49
- declare function createCollectionPageExports<S extends string = "pages">({ slug: collectionSlug, _payloadConfig, importMap, routing, slugShape }: CreateCollectionPageExportsArgs<S>, { getServerSideURL, pagePathPrefix, fallback }: CreateCollectionPageExportsDeps<S>): {
51
+ declare function createCollectionPageExports<S extends string = "pages">({ slug: collectionSlug, _payloadConfig, importMap, routing, slugShape, depth }: CreateCollectionPageExportsArgs<S>, { getServerSideURL, pagePathPrefix, fallback }: CreateCollectionPageExportsDeps<S>): {
50
52
  default: (props: NextPageProps) => Promise<ReactNode2>;
51
53
  generateMetadata: (props: NextPageProps) => Promise<Metadata>;
52
54
  generateStaticParams: (props: GenerateStaticParamsProps) => Promise<{
package/dist/pages.js CHANGED
@@ -225,6 +225,7 @@ async function requireCacheHelpers() {
225
225
  }
226
226
  throw new Error("[payload-www] seedPayloadCache({ config }) must be called before any query getter. " + "Call it from createCollectionPageExports / createRootLayoutExports factory, or in your root layout.");
227
227
  }
228
+ var RENDER_DEPTH = 2;
228
229
  async function queryDocBySlug(args) {
229
230
  "use cache";
230
231
  cacheLife("weeks");
@@ -235,7 +236,7 @@ async function queryDocBySlug(args) {
235
236
  locale: args.locale,
236
237
  draft: args.draft ?? false,
237
238
  overrideAccess: args.draft ?? false,
238
- depth: args.depth
239
+ depth: args.depth ?? RENDER_DEPTH
239
240
  });
240
241
  const result = await find(args.slug);
241
242
  const doc = result ?? (isIndexSlug(args.slug) ? await find(null) : null);
@@ -249,7 +250,7 @@ async function queryGlobal(args) {
249
250
  const result = await findGlobal(args.globalSlug, {
250
251
  locale: args.locale,
251
252
  draft: args.draft ?? false,
252
- depth: args.depth
253
+ depth: args.depth ?? RENDER_DEPTH
253
254
  });
254
255
  return result ?? null;
255
256
  } catch (error) {
@@ -265,7 +266,7 @@ async function queryAllDocs(args) {
265
266
  const { ids } = await findIds(collection, { locale: args.locale, pagination: false, overrideAccess: false });
266
267
  if (ids.length === 0)
267
268
  return [];
268
- const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false })));
269
+ const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false, depth: 0 })));
269
270
  return docs.filter((d) => d !== null);
270
271
  }
271
272
  async function queryDoc(args) {
@@ -292,7 +293,7 @@ async function queryDocByID(args) {
292
293
  locale: args.locale,
293
294
  draft: args.draft ?? false,
294
295
  overrideAccess: args.draft ?? false,
295
- depth: args.depth
296
+ depth: args.depth ?? RENDER_DEPTH
296
297
  });
297
298
  }
298
299
 
@@ -368,7 +369,8 @@ function createCollectionPageExports({
368
369
  _payloadConfig,
369
370
  importMap,
370
371
  routing,
371
- slugShape = "single"
372
+ slugShape = "single",
373
+ depth = RENDER_DEPTH
372
374
  }, {
373
375
  getServerSideURL,
374
376
  pagePathPrefix,
@@ -380,6 +382,7 @@ function createCollectionPageExports({
380
382
  return queryDoc({
381
383
  slug,
382
384
  locale,
385
+ depth,
383
386
  collectionSlug
384
387
  });
385
388
  }
@@ -48,6 +48,8 @@ type CreateCollectionPageExportsArgs<S extends string = "pages"> = {
48
48
  importMap: ImportMap3;
49
49
  routing: RoutingConfig;
50
50
  slugShape?: SlugShape;
51
+ /** Relationship / upload hops populated on the rendered document. `0` renders them as bare ids. */
52
+ depth?: number;
51
53
  };
52
54
  type CreateCollectionPageExportsDeps<S extends string> = {
53
55
  getServerSideURL: () => string;
@@ -55,7 +57,7 @@ type CreateCollectionPageExportsDeps<S extends string> = {
55
57
  /** Rendered while the document streams. Defaults to nothing. */
56
58
  fallback?: ReactNode2;
57
59
  };
58
- declare function createCollectionPageExports<S extends string = "pages">({ slug: collectionSlug, _payloadConfig, importMap, routing, slugShape }: CreateCollectionPageExportsArgs<S>, { getServerSideURL, pagePathPrefix, fallback }: CreateCollectionPageExportsDeps<S>): {
60
+ declare function createCollectionPageExports<S extends string = "pages">({ slug: collectionSlug, _payloadConfig, importMap, routing, slugShape, depth }: CreateCollectionPageExportsArgs<S>, { getServerSideURL, pagePathPrefix, fallback }: CreateCollectionPageExportsDeps<S>): {
59
61
  default: (props: NextPageProps) => Promise<ReactNode2>;
60
62
  generateMetadata: (props: NextPageProps) => Promise<Metadata>;
61
63
  generateStaticParams: (props: GenerateStaticParamsProps) => Promise<{
@@ -75,6 +77,8 @@ type CreateRootLayoutExportsArgs = {
75
77
  _payloadConfig: Promise<SanitizedConfig3>;
76
78
  importMap: ImportMap4;
77
79
  routing: RoutingConfig;
80
+ /** Relationship / upload hops populated on the header and footer globals. `0` renders them as bare ids. */
81
+ depth?: number;
78
82
  };
79
83
  type CreateRootLayoutProvidersArgs = {
80
84
  children: ReactNode3;
@@ -86,7 +90,7 @@ type CreateRootLayoutExportsDeps = {
86
90
  getServerSideURL?: () => string;
87
91
  };
88
92
  type Element_12xgc2 = JSX_1kxb2["Element"];
89
- declare function createRootLayoutExports({ _payloadConfig, importMap, routing }: CreateRootLayoutExportsArgs, { providers, htmlAttrs, getServerSideURL }?: CreateRootLayoutExportsDeps): {
93
+ declare function createRootLayoutExports({ _payloadConfig, importMap, routing, depth }: CreateRootLayoutExportsArgs, { providers, htmlAttrs, getServerSideURL }?: CreateRootLayoutExportsDeps): {
90
94
  default: (props: NextLayoutProps) => Promise<Element_12xgc2>;
91
95
  generateStaticParams: () => {
92
96
  locale: string;
@@ -255,6 +255,7 @@ async function requireCacheHelpers() {
255
255
  }
256
256
  throw new Error("[payload-www] seedPayloadCache({ config }) must be called before any query getter. " + "Call it from createCollectionPageExports / createRootLayoutExports factory, or in your root layout.");
257
257
  }
258
+ var RENDER_DEPTH = 2;
258
259
  async function queryDocBySlug(args) {
259
260
  "use cache";
260
261
  cacheLife("weeks");
@@ -265,7 +266,7 @@ async function queryDocBySlug(args) {
265
266
  locale: args.locale,
266
267
  draft: args.draft ?? false,
267
268
  overrideAccess: args.draft ?? false,
268
- depth: args.depth
269
+ depth: args.depth ?? RENDER_DEPTH
269
270
  });
270
271
  const result = await find(args.slug);
271
272
  const doc = result ?? (isIndexSlug(args.slug) ? await find(null) : null);
@@ -279,7 +280,7 @@ async function queryGlobal(args) {
279
280
  const result = await findGlobal(args.globalSlug, {
280
281
  locale: args.locale,
281
282
  draft: args.draft ?? false,
282
- depth: args.depth
283
+ depth: args.depth ?? RENDER_DEPTH
283
284
  });
284
285
  return result ?? null;
285
286
  } catch (error) {
@@ -295,7 +296,7 @@ async function queryAllDocs(args) {
295
296
  const { ids } = await findIds(collection, { locale: args.locale, pagination: false, overrideAccess: false });
296
297
  if (ids.length === 0)
297
298
  return [];
298
- const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false })));
299
+ const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false, depth: 0 })));
299
300
  return docs.filter((d) => d !== null);
300
301
  }
301
302
  async function queryDoc(args) {
@@ -322,7 +323,7 @@ async function queryDocByID(args) {
322
323
  locale: args.locale,
323
324
  draft: args.draft ?? false,
324
325
  overrideAccess: args.draft ?? false,
325
- depth: args.depth
326
+ depth: args.depth ?? RENDER_DEPTH
326
327
  });
327
328
  }
328
329
 
@@ -398,7 +399,8 @@ function createCollectionPageExports({
398
399
  _payloadConfig,
399
400
  importMap,
400
401
  routing,
401
- slugShape = "single"
402
+ slugShape = "single",
403
+ depth = RENDER_DEPTH
402
404
  }, {
403
405
  getServerSideURL,
404
406
  pagePathPrefix,
@@ -410,6 +412,7 @@ function createCollectionPageExports({
410
412
  return queryDoc({
411
413
  slug,
412
414
  locale,
415
+ depth,
413
416
  collectionSlug
414
417
  });
415
418
  }
@@ -535,7 +538,8 @@ async function resolveLocale(props) {
535
538
  function createRootLayoutExports({
536
539
  _payloadConfig,
537
540
  importMap,
538
- routing
541
+ routing,
542
+ depth = RENDER_DEPTH
539
543
  }, {
540
544
  providers,
541
545
  htmlAttrs,
@@ -553,8 +557,8 @@ function createRootLayoutExports({
553
557
  header,
554
558
  footer
555
559
  ] = await Promise.all([
556
- queryDoc({ globalSlug: "header", locale }),
557
- queryDoc({ globalSlug: "footer", locale })
560
+ queryDoc({ globalSlug: "header", locale, depth }),
561
+ queryDoc({ globalSlug: "footer", locale, depth })
558
562
  ]);
559
563
  const renderedHeader = renderWWWDataModule(header, { collectionSlug: "header", configPath: "globals", config: _payloadConfig, importMap }, { ...props, locale }), renderedFooter = renderWWWDataModule(footer, { collectionSlug: "footer", configPath: "globals", config: _payloadConfig, importMap }, { ...props, locale });
560
564
  const mergedHtmlAttrs = {
package/dist/sitemap.js CHANGED
@@ -50,6 +50,7 @@ async function requireCacheHelpers() {
50
50
  }
51
51
  throw new Error("[payload-www] seedPayloadCache({ config }) must be called before any query getter. " + "Call it from createCollectionPageExports / createRootLayoutExports factory, or in your root layout.");
52
52
  }
53
+ var RENDER_DEPTH = 2;
53
54
  async function queryDocBySlug(args) {
54
55
  "use cache";
55
56
  cacheLife("weeks");
@@ -60,7 +61,7 @@ async function queryDocBySlug(args) {
60
61
  locale: args.locale,
61
62
  draft: args.draft ?? false,
62
63
  overrideAccess: args.draft ?? false,
63
- depth: args.depth
64
+ depth: args.depth ?? RENDER_DEPTH
64
65
  });
65
66
  const result = await find(args.slug);
66
67
  const doc = result ?? (isIndexSlug(args.slug) ? await find(null) : null);
@@ -74,7 +75,7 @@ async function queryGlobal(args) {
74
75
  const result = await findGlobal(args.globalSlug, {
75
76
  locale: args.locale,
76
77
  draft: args.draft ?? false,
77
- depth: args.depth
78
+ depth: args.depth ?? RENDER_DEPTH
78
79
  });
79
80
  return result ?? null;
80
81
  } catch (error) {
@@ -90,7 +91,7 @@ async function queryAllDocs(args) {
90
91
  const { ids } = await findIds(collection, { locale: args.locale, pagination: false, overrideAccess: false });
91
92
  if (ids.length === 0)
92
93
  return [];
93
- const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false })));
94
+ const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false, depth: 0 })));
94
95
  return docs.filter((d) => d !== null);
95
96
  }
96
97
  async function queryDoc(args) {
@@ -117,7 +118,7 @@ async function queryDocByID(args) {
117
118
  locale: args.locale,
118
119
  draft: args.draft ?? false,
119
120
  overrideAccess: args.draft ?? false,
120
- depth: args.depth
121
+ depth: args.depth ?? RENDER_DEPTH
121
122
  });
122
123
  }
123
124
 
@@ -214,7 +215,8 @@ function createCollectionPageExports({
214
215
  _payloadConfig,
215
216
  importMap,
216
217
  routing,
217
- slugShape = "single"
218
+ slugShape = "single",
219
+ depth = RENDER_DEPTH
218
220
  }, {
219
221
  getServerSideURL,
220
222
  pagePathPrefix,
@@ -226,6 +228,7 @@ function createCollectionPageExports({
226
228
  return queryDoc({
227
229
  slug,
228
230
  locale,
231
+ depth,
229
232
  collectionSlug
230
233
  });
231
234
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justanarthur/payload-www",
3
3
  "description": "Reusable Payload CMS website template — config builder, collections, globals, blocks, fields, access, hooks, metadata (JSON-LD, hreflang), page renderers, and test helpers.",
4
- "version": "2.2.8",
4
+ "version": "2.2.9",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "files": [