@justanarthur/payload-www 2.2.5 → 2.2.6

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
@@ -112,8 +112,18 @@ const {
112
112
 
113
113
  export default Page
114
114
  export { generateMetadata, generateStaticParams, generateSitemap }
115
+
116
+ // the doc lookup blocks so unknown slugs can return a real 404
117
+ export const instant = false
115
118
  ```
116
119
 
120
+ The page looks up the document before it renders anything, so a missing slug returns HTTP 404
121
+ rather than a streamed not-found body with status 200. Slugs from `generateStaticParams`
122
+ prerender. Next renders any other slug on its first request, and blocks until the lookup is
123
+ done. `export const instant = false` tells Next's dev-time instant validation that the route
124
+ blocks on purpose. With `partialPrefetching: true`, Next streams the layout shell for slugs it did
125
+ not prerender, so those slugs still get a soft 404.
126
+
117
127
  `slugShape` is `'single'` (default) or `'catch-all'`. Use `'catch-all'` if your route segment is
118
128
  `[[...slug]]` (Pages-style), `'single'` for `[slug]` (Posts-style — file convention).
119
129
 
@@ -141,6 +151,7 @@ const { default: PostPage, generateMetadata, generateStaticParams } = createColl
141
151
  |---|---|---|
142
152
  | `getServerSideURL` | `() => string` | host's absolute-URL helper |
143
153
  | `pagePathPrefix` | `string \| Record<locale, string>` | URL segment the collection is mounted under, used for `generateSitemap` and for canonical/hreflang URLs. Pass a record to localize the segment (`{ en: 'posts', sk: 'prispevky' }`); locales absent from it fall back to the default locale. The sitemap *index* route always uses the default locale's segment. |
154
+ | `fallback` | `ReactNode` | rendered while the found document streams. Defaults to nothing. The lookup itself never streams, so a missing document still returns a 404. |
144
155
 
145
156
  ### What you get back
146
157
 
package/dist/cli.js CHANGED
@@ -34,9 +34,9 @@ function defaultBlockPath(slug) {
34
34
  }
35
35
  async function generateAsyncImportmap(config, options) {
36
36
  const pkg = options.packageName ?? name;
37
- const blocks = config.blocks ?? [] ?? [];
38
- const collections = config.collections ?? [] ?? [];
39
- const globals = config.globals ?? [] ?? [];
37
+ const blocks = config.blocks ?? [];
38
+ const collections = config.collections ?? [];
39
+ const globals = config.globals ?? [];
40
40
  const keys = new Set;
41
41
  for (const block of blocks) {
42
42
  if (!block.slug)
@@ -115,6 +115,7 @@ async function queryDocBySlug(args) {
115
115
  where: { [slugField]: { equals: args.slug } },
116
116
  locale: args.locale,
117
117
  draft: args.draft ?? false,
118
+ overrideAccess: args.draft ?? false,
118
119
  depth: args.depth
119
120
  });
120
121
  return result ?? null;
@@ -140,10 +141,10 @@ async function queryAllDocs(args) {
140
141
  cacheLife("weeks");
141
142
  const { findIds, findDocByID } = await requireCacheHelpers();
142
143
  const collection = args.collectionSlug;
143
- const { ids } = await findIds(collection, { locale: args.locale });
144
+ const { ids } = await findIds(collection, { locale: args.locale, pagination: false, overrideAccess: false });
144
145
  if (ids.length === 0)
145
146
  return [];
146
- const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale })));
147
+ const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false })));
147
148
  return docs.filter((d) => d !== null);
148
149
  }
149
150
  async function queryDoc(args) {
@@ -156,7 +157,7 @@ async function queryAllLocaleSlugs(args) {
156
157
  cacheLife("weeks");
157
158
  const { findDocByID } = await requireCacheHelpers();
158
159
  const slugField = args.slugField ?? "slug";
159
- const doc = await findDocByID(args.collectionSlug, args.id, { locale: "all", select: { [slugField]: true } });
160
+ const doc = await findDocByID(args.collectionSlug, args.id, { locale: "all", select: { [slugField]: true }, overrideAccess: false });
160
161
  const localeMap = doc?.[slugField];
161
162
  if (localeMap && typeof localeMap === "object")
162
163
  return localeMap;
@@ -169,6 +170,7 @@ async function queryDocByID(args) {
169
170
  return await findDocByID(args.collectionSlug, args.id, {
170
171
  locale: args.locale,
171
172
  draft: args.draft ?? false,
173
+ overrideAccess: args.draft ?? false,
172
174
  depth: args.depth
173
175
  });
174
176
  }
package/dist/metadata.js CHANGED
@@ -143,6 +143,7 @@ async function queryDocBySlug(args) {
143
143
  where: { [slugField]: { equals: args.slug } },
144
144
  locale: args.locale,
145
145
  draft: args.draft ?? false,
146
+ overrideAccess: args.draft ?? false,
146
147
  depth: args.depth
147
148
  });
148
149
  return result ?? null;
@@ -168,10 +169,10 @@ async function queryAllDocs(args) {
168
169
  cacheLife("weeks");
169
170
  const { findIds, findDocByID } = await requireCacheHelpers();
170
171
  const collection = args.collectionSlug;
171
- const { ids } = await findIds(collection, { locale: args.locale });
172
+ const { ids } = await findIds(collection, { locale: args.locale, pagination: false, overrideAccess: false });
172
173
  if (ids.length === 0)
173
174
  return [];
174
- const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale })));
175
+ const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false })));
175
176
  return docs.filter((d) => d !== null);
176
177
  }
177
178
  async function queryDoc(args) {
@@ -184,7 +185,7 @@ async function queryAllLocaleSlugs(args) {
184
185
  cacheLife("weeks");
185
186
  const { findDocByID } = await requireCacheHelpers();
186
187
  const slugField = args.slugField ?? "slug";
187
- const doc = await findDocByID(args.collectionSlug, args.id, { locale: "all", select: { [slugField]: true } });
188
+ const doc = await findDocByID(args.collectionSlug, args.id, { locale: "all", select: { [slugField]: true }, overrideAccess: false });
188
189
  const localeMap = doc?.[slugField];
189
190
  if (localeMap && typeof localeMap === "object")
190
191
  return localeMap;
@@ -197,6 +198,7 @@ async function queryDocByID(args) {
197
198
  return await findDocByID(args.collectionSlug, args.id, {
198
199
  locale: args.locale,
199
200
  draft: args.draft ?? false,
201
+ overrideAccess: args.draft ?? false,
200
202
  depth: args.depth
201
203
  });
202
204
  }
package/dist/pages.d.ts CHANGED
@@ -20,6 +20,10 @@ type NextPageProps = {
20
20
  slug?: string | string[];
21
21
  }>;
22
22
  };
23
+ type RouteParams = Record<string, string | string[] | undefined>;
24
+ type GenerateStaticParamsProps = {
25
+ params: RouteParams | Promise<RouteParams>;
26
+ };
23
27
  import { RoutingConfig as GenericRoutingConfig } from "next-intl/routing";
24
28
  type RoutingConfig = GenericRoutingConfig<string[], any, any, any>;
25
29
  /**
@@ -43,9 +47,9 @@ type CreateCollectionPageExportsDeps<S extends string> = {
43
47
  fallback?: ReactNode2;
44
48
  };
45
49
  declare function createCollectionPageExports<S extends string = "pages">({ slug: collectionSlug, _payloadConfig, importMap, routing, slugShape }: CreateCollectionPageExportsArgs<S>, { getServerSideURL, pagePathPrefix, fallback }: CreateCollectionPageExportsDeps<S>): {
46
- default: (props: NextPageProps) => ReactNode2;
50
+ default: (props: NextPageProps) => Promise<ReactNode2>;
47
51
  generateMetadata: (props: NextPageProps) => Promise<Metadata>;
48
- generateStaticParams: (props: NextPageProps) => Promise<{
52
+ generateStaticParams: (props: GenerateStaticParamsProps) => Promise<{
49
53
  locale: string;
50
54
  slug: string | string[];
51
55
  }[]>;
package/dist/pages.js CHANGED
@@ -228,6 +228,7 @@ async function queryDocBySlug(args) {
228
228
  where: { [slugField]: { equals: args.slug } },
229
229
  locale: args.locale,
230
230
  draft: args.draft ?? false,
231
+ overrideAccess: args.draft ?? false,
231
232
  depth: args.depth
232
233
  });
233
234
  return result ?? null;
@@ -253,10 +254,10 @@ async function queryAllDocs(args) {
253
254
  cacheLife("weeks");
254
255
  const { findIds, findDocByID } = await requireCacheHelpers();
255
256
  const collection = args.collectionSlug;
256
- const { ids } = await findIds(collection, { locale: args.locale });
257
+ const { ids } = await findIds(collection, { locale: args.locale, pagination: false, overrideAccess: false });
257
258
  if (ids.length === 0)
258
259
  return [];
259
- const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale })));
260
+ const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false })));
260
261
  return docs.filter((d) => d !== null);
261
262
  }
262
263
  async function queryDoc(args) {
@@ -269,7 +270,7 @@ async function queryAllLocaleSlugs(args) {
269
270
  cacheLife("weeks");
270
271
  const { findDocByID } = await requireCacheHelpers();
271
272
  const slugField = args.slugField ?? "slug";
272
- const doc = await findDocByID(args.collectionSlug, args.id, { locale: "all", select: { [slugField]: true } });
273
+ const doc = await findDocByID(args.collectionSlug, args.id, { locale: "all", select: { [slugField]: true }, overrideAccess: false });
273
274
  const localeMap = doc?.[slugField];
274
275
  if (localeMap && typeof localeMap === "object")
275
276
  return localeMap;
@@ -282,6 +283,7 @@ async function queryDocByID(args) {
282
283
  return await findDocByID(args.collectionSlug, args.id, {
283
284
  locale: args.locale,
284
285
  draft: args.draft ?? false,
286
+ overrideAccess: args.draft ?? false,
285
287
  depth: args.depth
286
288
  });
287
289
  }
@@ -352,7 +354,7 @@ async function renderWWWDataModule(data, {
352
354
  }
353
355
 
354
356
  // src/render/pages/createCollectionPageExports.tsx
355
- import { jsx as jsx6, Fragment as Fragment2 } from "react/jsx-runtime";
357
+ import { jsx as jsx6 } from "react/jsx-runtime";
356
358
  function createCollectionPageExports({
357
359
  slug: collectionSlug = "pages",
358
360
  _payloadConfig,
@@ -373,13 +375,7 @@ function createCollectionPageExports({
373
375
  collectionSlug
374
376
  });
375
377
  }
376
- const default_ = (props) => /* @__PURE__ */ jsx6(React.Suspense, {
377
- fallback: fallback ?? null,
378
- children: /* @__PURE__ */ jsx6(CollectionDocument, {
379
- ...props
380
- })
381
- });
382
- const CollectionDocument = async (props) => {
378
+ const default_ = async (props) => {
383
379
  const params = await props.params;
384
380
  const locale = params.locale;
385
381
  if (!routing.locales.includes(locale)) {
@@ -394,7 +390,8 @@ function createCollectionPageExports({
394
390
  notFound();
395
391
  }
396
392
  const rendered = renderWWWDataModule(doc, { collectionSlug, config: _payloadConfig, importMap }, { ...props, locale });
397
- return /* @__PURE__ */ jsx6(Fragment2, {
393
+ return /* @__PURE__ */ jsx6(React.Suspense, {
394
+ fallback: fallback ?? null,
398
395
  children: rendered
399
396
  });
400
397
  };
@@ -29,6 +29,10 @@ type NextLayoutProps = {
29
29
  }>;
30
30
  children: ReactNode;
31
31
  };
32
+ type RouteParams = Record<string, string | string[] | undefined>;
33
+ type GenerateStaticParamsProps = {
34
+ params: RouteParams | Promise<RouteParams>;
35
+ };
32
36
  import { RoutingConfig as GenericRoutingConfig } from "next-intl/routing";
33
37
  type RoutingConfig = GenericRoutingConfig<string[], any, any, any>;
34
38
  /**
@@ -52,9 +56,9 @@ type CreateCollectionPageExportsDeps<S extends string> = {
52
56
  fallback?: ReactNode2;
53
57
  };
54
58
  declare function createCollectionPageExports<S extends string = "pages">({ slug: collectionSlug, _payloadConfig, importMap, routing, slugShape }: CreateCollectionPageExportsArgs<S>, { getServerSideURL, pagePathPrefix, fallback }: CreateCollectionPageExportsDeps<S>): {
55
- default: (props: NextPageProps) => ReactNode2;
59
+ default: (props: NextPageProps) => Promise<ReactNode2>;
56
60
  generateMetadata: (props: NextPageProps) => Promise<Metadata>;
57
- generateStaticParams: (props: NextPageProps) => Promise<{
61
+ generateStaticParams: (props: GenerateStaticParamsProps) => Promise<{
58
62
  locale: string;
59
63
  slug: string | string[];
60
64
  }[]>;
@@ -258,6 +258,7 @@ async function queryDocBySlug(args) {
258
258
  where: { [slugField]: { equals: args.slug } },
259
259
  locale: args.locale,
260
260
  draft: args.draft ?? false,
261
+ overrideAccess: args.draft ?? false,
261
262
  depth: args.depth
262
263
  });
263
264
  return result ?? null;
@@ -283,10 +284,10 @@ async function queryAllDocs(args) {
283
284
  cacheLife("weeks");
284
285
  const { findIds, findDocByID } = await requireCacheHelpers();
285
286
  const collection = args.collectionSlug;
286
- const { ids } = await findIds(collection, { locale: args.locale });
287
+ const { ids } = await findIds(collection, { locale: args.locale, pagination: false, overrideAccess: false });
287
288
  if (ids.length === 0)
288
289
  return [];
289
- const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale })));
290
+ const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false })));
290
291
  return docs.filter((d) => d !== null);
291
292
  }
292
293
  async function queryDoc(args) {
@@ -299,7 +300,7 @@ async function queryAllLocaleSlugs(args) {
299
300
  cacheLife("weeks");
300
301
  const { findDocByID } = await requireCacheHelpers();
301
302
  const slugField = args.slugField ?? "slug";
302
- const doc = await findDocByID(args.collectionSlug, args.id, { locale: "all", select: { [slugField]: true } });
303
+ const doc = await findDocByID(args.collectionSlug, args.id, { locale: "all", select: { [slugField]: true }, overrideAccess: false });
303
304
  const localeMap = doc?.[slugField];
304
305
  if (localeMap && typeof localeMap === "object")
305
306
  return localeMap;
@@ -312,6 +313,7 @@ async function queryDocByID(args) {
312
313
  return await findDocByID(args.collectionSlug, args.id, {
313
314
  locale: args.locale,
314
315
  draft: args.draft ?? false,
316
+ overrideAccess: args.draft ?? false,
315
317
  depth: args.depth
316
318
  });
317
319
  }
@@ -382,7 +384,7 @@ async function renderWWWDataModule(data, {
382
384
  }
383
385
 
384
386
  // src/render/pages/createCollectionPageExports.tsx
385
- import { jsx as jsx7, Fragment as Fragment2 } from "react/jsx-runtime";
387
+ import { jsx as jsx7 } from "react/jsx-runtime";
386
388
  function createCollectionPageExports({
387
389
  slug: collectionSlug = "pages",
388
390
  _payloadConfig,
@@ -403,13 +405,7 @@ function createCollectionPageExports({
403
405
  collectionSlug
404
406
  });
405
407
  }
406
- const default_ = (props) => /* @__PURE__ */ jsx7(React.Suspense, {
407
- fallback: fallback ?? null,
408
- children: /* @__PURE__ */ jsx7(CollectionDocument, {
409
- ...props
410
- })
411
- });
412
- const CollectionDocument = async (props) => {
408
+ const default_ = async (props) => {
413
409
  const params = await props.params;
414
410
  const locale = params.locale;
415
411
  if (!routing.locales.includes(locale)) {
@@ -424,7 +420,8 @@ function createCollectionPageExports({
424
420
  notFound();
425
421
  }
426
422
  const rendered = renderWWWDataModule(doc, { collectionSlug, config: _payloadConfig, importMap }, { ...props, locale });
427
- return /* @__PURE__ */ jsx7(Fragment2, {
423
+ return /* @__PURE__ */ jsx7(React.Suspense, {
424
+ fallback: fallback ?? null,
428
425
  children: rendered
429
426
  });
430
427
  };
package/dist/sitemap.js CHANGED
@@ -53,6 +53,7 @@ async function queryDocBySlug(args) {
53
53
  where: { [slugField]: { equals: args.slug } },
54
54
  locale: args.locale,
55
55
  draft: args.draft ?? false,
56
+ overrideAccess: args.draft ?? false,
56
57
  depth: args.depth
57
58
  });
58
59
  return result ?? null;
@@ -78,10 +79,10 @@ async function queryAllDocs(args) {
78
79
  cacheLife("weeks");
79
80
  const { findIds, findDocByID } = await requireCacheHelpers();
80
81
  const collection = args.collectionSlug;
81
- const { ids } = await findIds(collection, { locale: args.locale });
82
+ const { ids } = await findIds(collection, { locale: args.locale, pagination: false, overrideAccess: false });
82
83
  if (ids.length === 0)
83
84
  return [];
84
- const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale })));
85
+ const docs = await Promise.all(ids.map((id) => findDocByID(collection, id, { locale: args.locale, overrideAccess: false })));
85
86
  return docs.filter((d) => d !== null);
86
87
  }
87
88
  async function queryDoc(args) {
@@ -94,7 +95,7 @@ async function queryAllLocaleSlugs(args) {
94
95
  cacheLife("weeks");
95
96
  const { findDocByID } = await requireCacheHelpers();
96
97
  const slugField = args.slugField ?? "slug";
97
- const doc = await findDocByID(args.collectionSlug, args.id, { locale: "all", select: { [slugField]: true } });
98
+ const doc = await findDocByID(args.collectionSlug, args.id, { locale: "all", select: { [slugField]: true }, overrideAccess: false });
98
99
  const localeMap = doc?.[slugField];
99
100
  if (localeMap && typeof localeMap === "object")
100
101
  return localeMap;
@@ -107,6 +108,7 @@ async function queryDocByID(args) {
107
108
  return await findDocByID(args.collectionSlug, args.id, {
108
109
  locale: args.locale,
109
110
  draft: args.draft ?? false,
111
+ overrideAccess: args.draft ?? false,
110
112
  depth: args.depth
111
113
  });
112
114
  }
@@ -198,7 +200,7 @@ async function renderWWWDataModule(data, {
198
200
  }
199
201
 
200
202
  // src/render/pages/createCollectionPageExports.tsx
201
- import { jsx as jsx2, Fragment } from "react/jsx-runtime";
203
+ import { jsx as jsx2 } from "react/jsx-runtime";
202
204
  function createCollectionPageExports({
203
205
  slug: collectionSlug = "pages",
204
206
  _payloadConfig,
@@ -219,13 +221,7 @@ function createCollectionPageExports({
219
221
  collectionSlug
220
222
  });
221
223
  }
222
- const default_ = (props) => /* @__PURE__ */ jsx2(React.Suspense, {
223
- fallback: fallback ?? null,
224
- children: /* @__PURE__ */ jsx2(CollectionDocument, {
225
- ...props
226
- })
227
- });
228
- const CollectionDocument = async (props) => {
224
+ const default_ = async (props) => {
229
225
  const params = await props.params;
230
226
  const locale = params.locale;
231
227
  if (!routing.locales.includes(locale)) {
@@ -240,7 +236,8 @@ function createCollectionPageExports({
240
236
  notFound();
241
237
  }
242
238
  const rendered = renderWWWDataModule(doc, { collectionSlug, config: _payloadConfig, importMap }, { ...props, locale });
243
- return /* @__PURE__ */ jsx2(Fragment, {
239
+ return /* @__PURE__ */ jsx2(React.Suspense, {
240
+ fallback: fallback ?? null,
244
241
  children: rendered
245
242
  });
246
243
  };
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.5",
4
+ "version": "2.2.6",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "files": [