@justanarthur/payload-www 0.3.2 → 0.3.4

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.
@@ -30,6 +30,7 @@ function PageShowcase({
30
30
  metadataHeading = "Page metadata",
31
31
  jsonLdHeading = "JSON-LD"
32
32
  }) {
33
+ console.log("[WWW] render/components:PageShowcase jsonLdEntries=", jsonLd.length, "hasOg=", Boolean(metadata.openGraph), "hasTwitter=", Boolean(metadata.twitter), "canonical=", metadata.alternates?.canonical);
33
34
  const og = metadata.openGraph;
34
35
  const twitter = metadata.twitter;
35
36
  const rows = [
@@ -147,6 +148,7 @@ function LocaleSwitcher({
147
148
  labels
148
149
  }) {
149
150
  const locales = Object.keys(hreflangAlternates).filter((k) => k !== "x-default");
151
+ console.log("[WWW] render/components:LocaleSwitcher currentLocale=", currentLocale, "locales=", JSON.stringify(locales), "hasXDefault=", Boolean(hreflangAlternates["x-default"]));
150
152
  return /* @__PURE__ */ jsx5("nav", {
151
153
  "aria-label": "Language",
152
154
  className: "locale-switcher",
@@ -200,20 +202,27 @@ var STATIC_PAGES_SLUG = "staticPages";
200
202
 
201
203
  // src/core/utils/getFromImportMap.ts
202
204
  function getFromImportMap(key, importMap) {
203
- return importMap[key.includes("#") ? key : key + "#default"];
205
+ const resolvedKey = key.includes("#") ? key : key + "#default";
206
+ const value = importMap[resolvedKey];
207
+ console.log("[WWW] core/utils:getFromImportMap key=", key, "resolved=", resolvedKey, "hit=", Boolean(value));
208
+ return value;
204
209
  }
205
210
 
206
211
  // src/render/utils/renderCollectionModule.tsx
207
212
  import { jsx } from "react/jsx-runtime";
208
213
  function renderCollectionModule(collection = [], slug, importMap, props) {
209
214
  const renderPath = collection?.find((c) => c.slug === slug)?.custom?.path;
210
- if (!renderPath)
215
+ if (!renderPath) {
216
+ console.log("[WWW] render/utils:renderCollectionModule no custom.path slug=", slug);
211
217
  return null;
218
+ }
212
219
  const CollectionRenderModule = getFromImportMap(renderPath, importMap);
213
220
  if (!CollectionRenderModule) {
221
+ console.error("[WWW] render/utils:renderCollectionModule not found slug=", slug, "path=", renderPath);
214
222
  if (false) {}
215
223
  return null;
216
224
  }
225
+ console.log("[WWW] render/utils:renderCollectionModule rendering slug=", slug, "path=", renderPath);
217
226
  return /* @__PURE__ */ jsx(CollectionRenderModule, {
218
227
  importMap,
219
228
  ...props
@@ -234,6 +243,7 @@ async function buildHreflangAlternates({
234
243
  localePrefix = "always"
235
244
  }) {
236
245
  const allLocaleSlugs = await queryAllLocaleSlugs(storedSlug, locale);
246
+ console.log("[WWW] render/metadata:buildHreflangAlternates storedSlug=", storedSlug, "locale=", locale, "allLocaleSlugs=", JSON.stringify(allLocaleSlugs));
237
247
  const languages = {};
238
248
  const urlFor = (l, slug) => {
239
249
  const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
@@ -251,6 +261,7 @@ async function buildHreflangAlternates({
251
261
  if (allLocaleSlugs?.[defaultLocale]) {
252
262
  languages["x-default"] = urlFor(defaultLocale, allLocaleSlugs[defaultLocale]);
253
263
  }
264
+ console.log("[WWW] render/metadata:buildHreflangAlternates ->", JSON.stringify(languages));
254
265
  return languages;
255
266
  }
256
267
 
@@ -265,6 +276,11 @@ function getImageUrl(doc, siteUrl) {
265
276
  return img.url.startsWith("http") ? img.url : `${siteUrl}${img.url}`;
266
277
  return null;
267
278
  }
279
+ function getImageUrlWithLog(doc, siteUrl) {
280
+ const result = getImageUrl(doc, siteUrl);
281
+ console.log("[WWW] render/metadata:jsonld:getImageUrl ->", result);
282
+ return result;
283
+ }
268
284
  function resolveLocalizedField(value, locale) {
269
285
  if (value == null)
270
286
  return "";
@@ -286,6 +302,13 @@ function resolveLocalizedField(value, locale) {
286
302
  }
287
303
  return Object.values(obj).filter((v) => typeof v === "string" && v.length > 0).join(" / ");
288
304
  }
305
+ function resolveLocalizedFieldWithLog(value, locale) {
306
+ const result = resolveLocalizedField(value, locale);
307
+ if (value && typeof value === "object") {
308
+ console.log("[WWW] render/metadata:jsonld:resolveLocalizedField locale=", locale, "->", JSON.stringify(result));
309
+ }
310
+ return result;
311
+ }
289
312
  function buildArticleLd({
290
313
  doc,
291
314
  url,
@@ -296,12 +319,13 @@ function buildArticleLd({
296
319
  publisherLogo
297
320
  }) {
298
321
  const name = publisherName ?? new URL(siteUrl).hostname;
322
+ console.log("[WWW] render/metadata:buildArticleLd url=", url, "locale=", locale, "type=", type, "publisherName=", name);
299
323
  const ld = {
300
324
  "@context": "https://schema.org",
301
325
  "@type": type,
302
326
  "@id": `${url}#article`,
303
- headline: resolveLocalizedField(doc.title, locale),
304
- description: resolveLocalizedField(doc.meta?.description ?? doc.description ?? doc.excerpt, locale),
327
+ headline: resolveLocalizedFieldWithLog(doc.title, locale),
328
+ description: resolveLocalizedFieldWithLog(doc.meta?.description ?? doc.description ?? doc.excerpt, locale),
305
329
  inLanguage: locale,
306
330
  url,
307
331
  dateModified: doc.updatedAt ? new Date(doc.updatedAt).toISOString() : undefined
@@ -309,7 +333,7 @@ function buildArticleLd({
309
333
  const datePublished = doc.publishedAt ?? doc.createdAt;
310
334
  if (datePublished)
311
335
  ld.datePublished = new Date(datePublished).toISOString();
312
- const imgUrl = getImageUrl(doc, siteUrl);
336
+ const imgUrl = getImageUrlWithLog(doc, siteUrl);
313
337
  if (imgUrl)
314
338
  ld.image = imgUrl;
315
339
  ld.author = { "@type": "Organization", name, url: siteUrl };
@@ -325,6 +349,7 @@ function buildBreadcrumbsLd({
325
349
  items,
326
350
  currentUrl
327
351
  }) {
352
+ console.log("[WWW] render/metadata:buildBreadcrumbsLd items=", items.length, "currentUrl=", currentUrl);
328
353
  return {
329
354
  "@context": "https://schema.org",
330
355
  "@type": "BreadcrumbList",
@@ -342,6 +367,7 @@ function buildOrganizationLd({
342
367
  logo,
343
368
  sameAs
344
369
  }) {
370
+ console.log("[WWW] render/metadata:buildOrganizationLd siteUrl=", siteUrl, "name=", name, "logo?", Boolean(logo), "sameAs?", Boolean(sameAs));
345
371
  const org = {
346
372
  "@context": "https://schema.org",
347
373
  "@type": "Organization",
@@ -357,23 +383,29 @@ function buildOrganizationLd({
357
383
  // src/render/metadata/slug.ts
358
384
  var SLUG_NESTED_DIVIDER = "_";
359
385
  function segmentsToStoredSlug(segments, nested) {
360
- if (!Array.isArray(segments))
386
+ if (!Array.isArray(segments)) {
387
+ console.log("[WWW] render/metadata:segmentsToStoredSlug string passthrough:", JSON.stringify(segments));
361
388
  return segments;
362
- if (nested)
363
- return segments.join(SLUG_NESTED_DIVIDER);
364
- return segments[0] ?? "";
389
+ }
390
+ const result = nested ? segments.join(SLUG_NESTED_DIVIDER) : segments[0] ?? "";
391
+ console.log("[WWW] render/metadata:segmentsToStoredSlug nested=", nested, "segments=", JSON.stringify(segments), "->", result);
392
+ return result;
365
393
  }
366
394
  function segmentsToUrlPath(segments, nested) {
395
+ let result;
367
396
  if (!Array.isArray(segments))
368
- return "/" + segments;
369
- if (nested)
370
- return "/" + segments.join("/");
371
- return "/" + (segments[0] ?? "");
397
+ result = "/" + segments;
398
+ else if (nested)
399
+ result = "/" + segments.join("/");
400
+ else
401
+ result = "/" + (segments[0] ?? "");
402
+ console.log("[WWW] render/metadata:segmentsToUrlPath nested=", nested, "segments=", JSON.stringify(segments), "->", result);
403
+ return result;
372
404
  }
373
405
  function storedSlugToSegments(storedSlug, nested) {
374
- if (nested)
375
- return storedSlug.split(SLUG_NESTED_DIVIDER);
376
- return storedSlug;
406
+ const result = nested ? storedSlug.split(SLUG_NESTED_DIVIDER) : storedSlug;
407
+ console.log("[WWW] render/metadata:storedSlugToSegments nested=", nested, "storedSlug=", storedSlug, "->", JSON.stringify(result));
408
+ return result;
377
409
  }
378
410
  function buildCanonicalUrl({
379
411
  siteUrl,
@@ -383,7 +415,9 @@ function buildCanonicalUrl({
383
415
  }) {
384
416
  const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
385
417
  const prefixSegment = trimmedPrefix ? `/${trimmedPrefix}` : "";
386
- return `${siteUrl}/${locale}${prefixSegment}${urlPath}`;
418
+ const result = `${siteUrl}/${locale}${prefixSegment}${urlPath}`;
419
+ console.log("[WWW] render/metadata:buildCanonicalUrl siteUrl=", siteUrl, "locale=", locale, "urlPrefix=", urlPrefix, "urlPath=", urlPath, "->", result);
420
+ return result;
387
421
  }
388
422
  function getUrlPath(segments, nested, homeSlug) {
389
423
  const urlPath = segmentsToUrlPath(segments, nested);
@@ -409,6 +443,7 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
409
443
  draft = false,
410
444
  config
411
445
  }) {
446
+ console.log("[WWW] render/metadata:queryDocBySlug collection=", collectionSlug, "slug=", slug, "slugField=", slugField, "locale=", locale, "draft=", draft);
412
447
  const payload = await getPayload({ config });
413
448
  const result = await payload.find({
414
449
  collection: collectionSlug,
@@ -419,7 +454,9 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
419
454
  where: { [slugField]: { equals: slug } },
420
455
  locale
421
456
  });
422
- return result.docs?.[0] ?? null;
457
+ const doc = result.docs?.[0] ?? null;
458
+ console.log("[WWW] render/metadata:queryDocBySlug ->", doc ? "hit" : "miss");
459
+ return doc;
423
460
  });
424
461
  var queryAllDocs = cache(async function queryAllDocs2({
425
462
  collectionSlug,
@@ -427,6 +464,7 @@ var queryAllDocs = cache(async function queryAllDocs2({
427
464
  locale,
428
465
  config
429
466
  }) {
467
+ console.log("[WWW] render/metadata:queryAllDocs collection=", collectionSlug, "locale=", locale);
430
468
  const payload = await getPayload({ config });
431
469
  const result = await payload.find({
432
470
  collection: collectionSlug,
@@ -437,7 +475,9 @@ var queryAllDocs = cache(async function queryAllDocs2({
437
475
  select: { [slugField]: true },
438
476
  locale
439
477
  });
440
- return result.docs ?? [];
478
+ const docs = result.docs ?? [];
479
+ console.log("[WWW] render/metadata:queryAllDocs -> count=", docs.length);
480
+ return docs;
441
481
  });
442
482
  var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
443
483
  collectionSlug,
@@ -446,6 +486,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
446
486
  locale,
447
487
  config
448
488
  }) {
489
+ console.log("[WWW] render/metadata:queryAllLocaleSlugs collection=", collectionSlug, "slug=", slug, "locale=", locale);
449
490
  const payload = await getPayload({ config });
450
491
  const result = await payload.find({
451
492
  collection: collectionSlug,
@@ -458,8 +499,10 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
458
499
  select: { [slugField]: true }
459
500
  });
460
501
  const doc = result.docs?.[0];
461
- if (!doc)
502
+ if (!doc) {
503
+ console.log("[WWW] render/metadata:queryAllLocaleSlugs -> undefined (no doc)");
462
504
  return;
505
+ }
463
506
  let fieldValue = doc[slugField];
464
507
  if (doc.id != null) {
465
508
  const allLocales = await payload.findByID({
@@ -474,6 +517,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
474
517
  fieldValue = allLocales[slugField];
475
518
  }
476
519
  if (fieldValue && typeof fieldValue === "object") {
520
+ console.log("[WWW] render/metadata:queryAllLocaleSlugs -> localized map=", JSON.stringify(fieldValue));
477
521
  return fieldValue;
478
522
  }
479
523
  const resolved = await config;
@@ -481,6 +525,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
481
525
  const out = {};
482
526
  for (const l of rawLocales)
483
527
  out[l] = String(fieldValue ?? slug);
528
+ console.log("[WWW] render/metadata:queryAllLocaleSlugs -> flat-fanout locales=", rawLocales.length, "slug=", JSON.stringify(fieldValue ?? slug));
484
529
  return out;
485
530
  });
486
531
  var queryGlobal = cache(async function queryGlobal2({
@@ -490,6 +535,7 @@ var queryGlobal = cache(async function queryGlobal2({
490
535
  draft = false,
491
536
  config
492
537
  }) {
538
+ console.log("[WWW] render/metadata:queryGlobal global=", globalSlug, "locale=", locale, "depth=", depth, "draft=", draft);
493
539
  const payload = await getPayload({ config });
494
540
  try {
495
541
  const global = await payload.findGlobal({
@@ -498,17 +544,23 @@ var queryGlobal = cache(async function queryGlobal2({
498
544
  draft,
499
545
  locale
500
546
  });
547
+ console.log("[WWW] render/metadata:queryGlobal -> hit");
501
548
  return global;
502
- } catch {
549
+ } catch (error) {
550
+ console.warn("[WWW] render/metadata:queryGlobal failed for slug=", globalSlug, "err=", String(error));
503
551
  return null;
504
552
  }
505
553
  });
506
554
  function getRenderModuleExports(exportName, collection, importMap) {
507
555
  const path = collection?.custom?.path;
508
- if (!path)
556
+ if (!path) {
557
+ console.log("[WWW] render/metadata:getRenderModuleExports no custom.path exportName=", exportName);
509
558
  return;
559
+ }
510
560
  const mod = getFromImportMap(path, importMap);
511
- return mod?.[exportName];
561
+ const value = mod?.[exportName];
562
+ console.log("[WWW] render/metadata:getRenderModuleExports exportName=", exportName, "path=", path, "hit=", Boolean(value));
563
+ return value;
512
564
  }
513
565
 
514
566
  // src/render/pages/createCollectionPageExports.tsx
@@ -517,11 +569,18 @@ import { RichText } from "@payloadcms/richtext-lexical/react";
517
569
  // src/core/utils/generateImportName.ts
518
570
  function generateImportName(type, slug) {
519
571
  switch (type) {
520
- case "block":
521
- return `Block${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
522
- case "page":
523
- return `Page${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
572
+ case "block": {
573
+ const name = `Block${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
574
+ console.log("[WWW] core/utils:generateImportName type=block slug=", slug, "->", name);
575
+ return name;
576
+ }
577
+ case "page": {
578
+ const name = `Page${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
579
+ console.log("[WWW] core/utils:generateImportName type=page slug=", slug, "->", name);
580
+ return name;
581
+ }
524
582
  default:
583
+ console.error("[WWW] core/utils:generateImportName unknown type:", type);
525
584
  throw new Error(`Unknown type: ${type}`);
526
585
  }
527
586
  }
@@ -536,8 +595,11 @@ var RenderBlocks = ({
536
595
  locale,
537
596
  searchParams
538
597
  }) => {
539
- if (!blocks || !Array.isArray(blocks) || blocks.length === 0)
598
+ if (!blocks || !Array.isArray(blocks) || blocks.length === 0) {
599
+ console.log("[WWW] render/blocks:RenderBlocks no blocks (locale=", locale, ")");
540
600
  return null;
601
+ }
602
+ console.log("[WWW] render/blocks:RenderBlocks rendering count=", blocks.length, "locale=", locale);
541
603
  const rendered = [];
542
604
  for (let i = 0;i < blocks.length; i++) {
543
605
  const block = blocks[i];
@@ -545,9 +607,10 @@ var RenderBlocks = ({
545
607
  const importMapPath = config.admin?.dependencies?.[blockType]?.path ?? generateImportName("block", blockType);
546
608
  const Block = getFromImportMap(importMapPath, importMap);
547
609
  if (!Block) {
548
- console.warn(`No block found for type: ${blockType}, config.admin?.dependencies?.[blockType]: ${config.admin?.dependencies?.[blockType]}`);
610
+ console.warn(`[WWW] render/blocks:RenderBlocks no block for type=${blockType} importMapPath=${importMapPath} (locale=${locale})`);
549
611
  continue;
550
612
  }
613
+ console.log("[WWW] render/blocks:RenderBlocks [", i, "] blockType=", blockType, "importMapPath=", importMapPath);
551
614
  rendered.push(/* @__PURE__ */ jsx2(Block, {
552
615
  index: i,
553
616
  ...blockProps,
@@ -564,9 +627,12 @@ var RenderBlocks = ({
564
627
  // src/render/pages/PagesPage.tsx
565
628
  import { jsx as jsx3, Fragment as Fragment2 } from "react/jsx-runtime";
566
629
  async function PagesPage({ doc, ...props }) {
567
- if (!doc)
630
+ if (!doc) {
631
+ console.log("[WWW] render/pages:PagesPage no doc");
568
632
  return /* @__PURE__ */ jsx3(Fragment2, {});
633
+ }
569
634
  const blocks = doc.blocks ?? [];
635
+ console.log("[WWW] render/pages:PagesPage blocks=", blocks.length, "locale=", props.locale);
570
636
  return /* @__PURE__ */ jsx3(Fragment2, {
571
637
  children: /* @__PURE__ */ jsx3(RenderBlocks, {
572
638
  blocks,
@@ -604,11 +670,15 @@ function createCollectionPageExports({
604
670
  const localePrefixMode = typeof routing.localePrefix === "string" ? routing.localePrefix : routing.localePrefix?.mode ?? "always";
605
671
  const buildLocalePath = (locale, storedSlug) => {
606
672
  const urlPath = getUrlPath(storedSlugToSegments(storedSlug, nested), nested, HOME_SLUG);
673
+ let result;
607
674
  if (localePrefixMode === "never")
608
- return urlPath;
609
- if (localePrefixMode === "as-needed" && locale === defaultLocale)
610
- return urlPath;
611
- return `/${locale}${urlPath}`;
675
+ result = urlPath;
676
+ else if (localePrefixMode === "as-needed" && locale === defaultLocale)
677
+ result = urlPath;
678
+ else
679
+ result = `/${locale}${urlPath}`;
680
+ console.log("[WWW] render/pages:createCollectionPageExports:buildLocalePath locale=", locale, "storedSlug=", storedSlug, "->", result);
681
+ return result;
612
682
  };
613
683
  async function fetchDoc(locale, storedSlug, draft = false) {
614
684
  return queryDocBySlug({
@@ -639,13 +709,16 @@ function createCollectionPageExports({
639
709
  for (const [key, url] of Object.entries(languages)) {
640
710
  alternates[key] = url;
641
711
  }
712
+ console.log("[WWW] render/pages:createCollectionPageExports:resolveHreflangAlternates canonical=", canonical, "alts=", JSON.stringify(alternates));
642
713
  return { alternates, canonical };
643
714
  }
644
715
  const default_ = async (props) => {
645
716
  const { slug: rawSlugSegments, locale: incomingLocale } = await props.params ?? {};
646
717
  const slugSegments = Array.isArray(rawSlugSegments) ? rawSlugSegments : [];
647
718
  const locale = typeof incomingLocale === "string" ? incomingLocale : defaultLocale;
719
+ console.log("[WWW] render/pages:createCollectionPageExports:default_ collectionSlug=", slug, "locale=", locale, "segments=", JSON.stringify(slugSegments), "showcase=", showcaseEnabled);
648
720
  if (!locales.includes(locale)) {
721
+ console.error(`[WWW] render/pages:createCollectionPageExports:default_ notFound invalid-locale collection=${slug} locale=${locale} segments=${JSON.stringify(slugSegments)}`);
649
722
  const { notFound } = await import("next/navigation");
650
723
  notFound();
651
724
  }
@@ -653,15 +726,18 @@ function createCollectionPageExports({
653
726
  setRequestLocale(locale);
654
727
  const { draftMode } = await import("next/headers");
655
728
  const { isEnabled: draft } = await draftMode();
729
+ console.log("[WWW] render/pages:createCollectionPageExports:default_ draftMode=", draft);
656
730
  const storedSlug = segmentsToStoredSlug(slugSegments, nested);
657
731
  const doc = await fetchDoc(locale, storedSlug, draft);
658
732
  if (!doc) {
733
+ console.error(`[WWW] render/pages:createCollectionPageExports:default_ notFound no-doc collection=${slug} locale=${locale} storedSlug="${storedSlug}" segments=${JSON.stringify(slugSegments)} draft=${draft}`);
659
734
  const { notFound } = await import("next/navigation");
660
735
  notFound();
661
736
  }
662
737
  const cfg = await configPromise;
663
738
  const collectionCustomPath = cfg.collections.find((c) => c.slug === slug)?.custom?.path;
664
739
  const effectivePath = renderPath ?? collectionCustomPath ?? defaultRenderPath;
740
+ console.log("[WWW] render/pages:createCollectionPageExports:default_ effectivePath=", effectivePath);
665
741
  const render = effectivePath === PAGES_RENDER_PATH ? /* @__PURE__ */ jsx6(PagesPage, {
666
742
  doc,
667
743
  importMap,
@@ -723,15 +799,22 @@ function createCollectionPageExports({
723
799
  const { slug: rawSlugSegments, locale: incomingLocale } = await props.params ?? {};
724
800
  const slugSegments = Array.isArray(rawSlugSegments) ? rawSlugSegments : [];
725
801
  const locale = typeof incomingLocale === "string" ? incomingLocale : defaultLocale;
726
- if (!locales.includes(locale))
802
+ console.log("[WWW] render/pages:createCollectionPageExports:generateMetadata collectionSlug=", slug, "locale=", locale, "segments=", JSON.stringify(slugSegments));
803
+ if (!locales.includes(locale)) {
804
+ console.log("[WWW] render/pages:createCollectionPageExports:generateMetadata invalid locale -> not found meta");
727
805
  return { title: "Not found", robots: { index: false, follow: false } };
806
+ }
728
807
  const storedSlug = segmentsToStoredSlug(slugSegments, nested);
729
808
  const doc = await fetchDoc(locale, storedSlug);
730
- if (!doc)
809
+ if (!doc) {
810
+ console.log("[WWW] render/pages:createCollectionPageExports:generateMetadata no doc -> not found meta");
731
811
  return { title: "Not found", robots: { index: false, follow: false } };
812
+ }
732
813
  const collection = cfg.collections.find((c) => c.slug === slug);
733
- if (!collection)
814
+ if (!collection) {
815
+ console.warn("[WWW] render/pages:createCollectionPageExports:generateMetadata collection not in config slug=", slug);
734
816
  return {};
817
+ }
735
818
  const { canonical, alternates } = await resolveHreflangAlternates(locale, storedSlug);
736
819
  const meta = await generateMeta({
737
820
  doc,
@@ -753,6 +836,7 @@ function createCollectionPageExports({
753
836
  const urlPath = buildLocalePath(locale, storedSlug);
754
837
  const canonical = `${siteUrl}${urlPath}`;
755
838
  const entries = Array.isArray(jsonLdOption) ? jsonLdOption : metadataType === "article" ? [{ type: "article" }] : [{ type: "website" }];
839
+ console.log("[WWW] render/pages:createCollectionPageExports:generateJsonLd collection=", slug, "locale=", locale, "entries=", entries.map((e) => e.type).join(","));
756
840
  const outputs = [];
757
841
  for (const entry of entries) {
758
842
  const id = entry.id ?? `jsonld-${entry.type}-${outputs.length}`;
@@ -813,6 +897,7 @@ function createCollectionPageExports({
813
897
  return outputs;
814
898
  }
815
899
  async function generateStaticParams() {
900
+ console.log("[WWW] render/pages:createCollectionPageExports:generateStaticParams collection=", slug, "locales=", JSON.stringify(locales));
816
901
  const params = [];
817
902
  for (const locale of locales) {
818
903
  const docs = await queryAllDocs({ collectionSlug: slug, slugField: "slug", locale, config: configPromise });
@@ -824,9 +909,11 @@ function createCollectionPageExports({
824
909
  params.push({ slug: Array.isArray(segments) ? segments : [segments], locale });
825
910
  }
826
911
  }
912
+ console.log("[WWW] render/pages:createCollectionPageExports:generateStaticParams -> count=", params.length);
827
913
  return params;
828
914
  }
829
915
  async function generateSitemap() {
916
+ console.log("[WWW] render/pages:createCollectionPageExports:generateSitemap collection=", slug, "locales=", JSON.stringify(locales));
830
917
  const docs = await queryAllDocs({
831
918
  collectionSlug: slug,
832
919
  slugField: "slug",
@@ -846,6 +933,7 @@ function createCollectionPageExports({
846
933
  urls.push({ url: `${siteUrl}${urlPath}`, lastModified: lastmod, changeFrequency: changefreq, priority });
847
934
  }
848
935
  }
936
+ console.log("[WWW] render/pages:createCollectionPageExports:generateSitemap -> urls=", urls.length);
849
937
  return urls;
850
938
  }
851
939
  return {
@@ -901,13 +989,17 @@ import"server-only";
901
989
  import { jsx as jsx7 } from "react/jsx-runtime";
902
990
  function renderGlobalModule(globals = [], slug, importMap, props) {
903
991
  const renderPath = globals?.find((g) => g.slug === slug)?.custom?.path;
904
- if (!renderPath)
992
+ if (!renderPath) {
993
+ console.log("[WWW] render/utils:renderGlobalModule no custom.path slug=", slug);
905
994
  return null;
995
+ }
906
996
  const GlobalRenderModule = getFromImportMap(renderPath, importMap);
907
997
  if (!GlobalRenderModule) {
998
+ console.error("[WWW] render/utils:renderGlobalModule not found slug=", slug, "path=", renderPath);
908
999
  if (false) {}
909
1000
  return null;
910
1001
  }
1002
+ console.log("[WWW] render/utils:renderGlobalModule rendering slug=", slug, "path=", renderPath);
911
1003
  return /* @__PURE__ */ jsx7(GlobalRenderModule, {
912
1004
  importMap,
913
1005
  ...props
@@ -923,7 +1015,9 @@ function createRootLayoutExports(args) {
923
1015
  params
924
1016
  }) {
925
1017
  const { locale } = await params;
1018
+ console.log("[WWW] render/pages:createRootLayoutExports:RootLayout locale=", locale);
926
1019
  if (!routing.locales.includes(locale)) {
1020
+ console.error("[WWW] render/pages:createRootLayoutExports:RootLayout invalid locale=", locale);
927
1021
  const { notFound } = await import("next/navigation");
928
1022
  notFound();
929
1023
  }
@@ -932,11 +1026,13 @@ function createRootLayoutExports(args) {
932
1026
  const messages = await getMessages();
933
1027
  const { draftMode: nextDraftMode } = await import("next/headers");
934
1028
  const { isEnabled: draftMode } = await nextDraftMode();
1029
+ console.log("[WWW] render/pages:createRootLayoutExports:RootLayout draftMode=", draftMode);
935
1030
  const cfg = await configPromise;
936
1031
  const [headerData, footerData] = await Promise.all([
937
1032
  queryGlobal({ globalSlug: "header", locale, depth: 0, config: configPromise }),
938
1033
  queryGlobal({ globalSlug: "footer", locale, depth: 0, config: configPromise })
939
1034
  ]);
1035
+ console.log("[WWW] render/pages:createRootLayoutExports:RootLayout header?", Boolean(headerData), "footer?", Boolean(footerData));
940
1036
  const headerEl = renderGlobalModule(cfg.globals, "header", importMap, {
941
1037
  data: headerData,
942
1038
  locale
@@ -985,40 +1081,65 @@ function createRootLayoutExports(args) {
985
1081
  import"server-only";
986
1082
 
987
1083
  // src/core/access/index.ts
988
- var anyone = () => true;
989
- var authenticated = ({ req: { user } }) => Boolean(user);
1084
+ var anyone = () => {
1085
+ console.log("[WWW] core/access:anyone -> true");
1086
+ return true;
1087
+ };
1088
+ var authenticated = ({ req: { user } }) => {
1089
+ const result = Boolean(user);
1090
+ console.log("[WWW] core/access:authenticated ->", result);
1091
+ return result;
1092
+ };
990
1093
  var authenticatedOrPublished = ({ req: { user } }) => {
991
- if (user)
1094
+ if (user) {
1095
+ console.log("[WWW] core/access:authenticatedOrPublished -> true (authenticated)");
992
1096
  return true;
1097
+ }
1098
+ console.log('[WWW] core/access:authenticatedOrPublished -> { _status: { equals: "published" } }');
993
1099
  return { _status: { equals: "published" } };
994
1100
  };
995
1101
 
996
1102
  // src/render/_locale.ts
997
1103
  function prefixFor(locale, defaultLocale, mode) {
1104
+ let result;
998
1105
  if (mode === "never")
999
- return "";
1000
- if (mode === "as-needed" && locale === defaultLocale)
1001
- return "";
1002
- return `/${locale}`;
1106
+ result = "";
1107
+ else if (mode === "as-needed" && locale === defaultLocale)
1108
+ result = "";
1109
+ else
1110
+ result = `/${locale}`;
1111
+ console.log("[WWW] render/_locale:prefixFor locale=", locale, "default=", defaultLocale, "mode=", mode, "->", JSON.stringify(result));
1112
+ return result;
1003
1113
  }
1004
1114
  function resolveLocale(req) {
1005
- if (!req || typeof req !== "object")
1115
+ if (!req || typeof req !== "object") {
1116
+ console.log('[WWW] render/_locale:resolveLocale -> "" (no req)');
1006
1117
  return "";
1118
+ }
1007
1119
  const r = req;
1008
- if (typeof r.locale === "string" && r.locale.length > 0)
1120
+ if (typeof r.locale === "string" && r.locale.length > 0) {
1121
+ console.log("[WWW] render/_locale:resolveLocale ->", r.locale, "(from req.locale)");
1009
1122
  return r.locale;
1123
+ }
1010
1124
  const fallback = r.payload?.config?.localization?.defaultLocale;
1011
- if (typeof fallback === "string" && fallback.length > 0)
1125
+ if (typeof fallback === "string" && fallback.length > 0) {
1126
+ console.log("[WWW] render/_locale:resolveLocale ->", fallback, "(from config.localization.defaultLocale)");
1012
1127
  return fallback;
1128
+ }
1129
+ console.log('[WWW] render/_locale:resolveLocale -> "" (no locale anywhere)');
1013
1130
  return "";
1014
1131
  }
1015
1132
  function allLocales(req) {
1016
- if (!req || typeof req !== "object")
1133
+ if (!req || typeof req !== "object") {
1134
+ console.log("[WWW] render/_locale:allLocales -> [] (no req)");
1017
1135
  return [];
1136
+ }
1018
1137
  const r = req;
1019
1138
  const list = r.payload?.config?.localization?.locales;
1020
- if (!Array.isArray(list) || list.length === 0)
1139
+ if (!Array.isArray(list) || list.length === 0) {
1140
+ console.log("[WWW] render/_locale:allLocales -> [] (no locales declared)");
1021
1141
  return [];
1142
+ }
1022
1143
  const out = [];
1023
1144
  for (const entry of list) {
1024
1145
  if (typeof entry === "string" && entry.length > 0) {
@@ -1029,6 +1150,7 @@ function allLocales(req) {
1029
1150
  out.push(code);
1030
1151
  }
1031
1152
  }
1153
+ console.log("[WWW] render/_locale:allLocales ->", JSON.stringify(out));
1032
1154
  return out;
1033
1155
  }
1034
1156
 
@@ -1038,21 +1160,28 @@ function nextCacheImport() {
1038
1160
  return cachePromise ??= import("next/cache");
1039
1161
  }
1040
1162
  function shouldSkipRevalidate(context) {
1041
- return Boolean(context?.disableRevalidate);
1163
+ const skip = Boolean(context?.disableRevalidate);
1164
+ if (skip)
1165
+ console.log("[WWW] render/hooks:_shared:shouldSkipRevalidate -> skip");
1166
+ return skip;
1042
1167
  }
1043
1168
  async function safeRevalidatePath(payload, path) {
1169
+ console.log("[WWW] render/hooks:_shared:safeRevalidatePath path=", path);
1044
1170
  try {
1045
1171
  const { revalidatePath } = await nextCacheImport();
1046
1172
  revalidatePath(path);
1047
1173
  } catch (error) {
1174
+ console.error("[WWW] render/hooks:_shared:safeRevalidatePath failed path=", path, "err=", String(error));
1048
1175
  payload.logger.error(`revalidatePath("${path}") failed: ${String(error)}`);
1049
1176
  }
1050
1177
  }
1051
1178
  async function safeRevalidateTag(payload, tag, profile = "max") {
1179
+ console.log("[WWW] render/hooks:_shared:safeRevalidateTag tag=", tag, "profile=", profile);
1052
1180
  try {
1053
1181
  const { revalidateTag } = await nextCacheImport();
1054
1182
  revalidateTag(tag, profile);
1055
1183
  } catch (error) {
1184
+ console.error("[WWW] render/hooks:_shared:safeRevalidateTag failed tag=", tag, "err=", String(error));
1056
1185
  payload.logger.error(`revalidateTag("${tag}") failed: ${String(error)}`);
1057
1186
  }
1058
1187
  }
@@ -1068,6 +1197,7 @@ function createRevalidateCollectionHook(options) {
1068
1197
  pathMode = "url"
1069
1198
  } = options;
1070
1199
  const resolvedSitemapTag = sitemapTag === false ? false : sitemapTag ?? `${collectionSlug}-sitemap`;
1200
+ console.log("[WWW] render/hooks:createRevalidateCollectionHook collectionSlug=", collectionSlug, "urlPathPrefix=", urlPathPrefix, "sitemapTag=", resolvedSitemapTag, "pathMode=", pathMode);
1071
1201
  const resolveDefaults = (req) => {
1072
1202
  const mode = modeOption ?? "always";
1073
1203
  const defaultLocale = defaultLocaleOption ?? req?.payload?.config?.localization?.defaultLocale ?? "";
@@ -1096,6 +1226,7 @@ function createRevalidateCollectionHook(options) {
1096
1226
  }
1097
1227
  };
1098
1228
  const fireCollectionTags = async (payload, docId, req) => {
1229
+ console.log("[WWW] render/hooks:fireCollectionTags collectionSlug=", collectionSlug, "docId=", docId);
1099
1230
  if (typeof docId === "string" || typeof docId === "number") {
1100
1231
  await safeRevalidateTag(payload, `collection_${collectionSlug}_${docId}`);
1101
1232
  }
@@ -1109,6 +1240,7 @@ function createRevalidateCollectionHook(options) {
1109
1240
  const { payload } = req;
1110
1241
  const typed = doc;
1111
1242
  const prev = previousDoc;
1243
+ console.log("[WWW] render/hooks:afterChange collectionSlug=", collectionSlug, "id=", typed.id, "slug=", typed.slug, "prevSlug=", prev?.slug);
1112
1244
  const isPublished = typed._status === "published";
1113
1245
  const wasPublished = prev?._status === "published";
1114
1246
  const prevSlugIsString = typeof prev?.slug === "string";
@@ -1132,6 +1264,7 @@ function createRevalidateCollectionHook(options) {
1132
1264
  return doc ?? null;
1133
1265
  const { payload } = req;
1134
1266
  const typed = doc;
1267
+ console.log("[WWW] render/hooks:afterDelete collectionSlug=", collectionSlug, "id=", typed?.id, "slug=", typed?.slug);
1135
1268
  if (pathMode !== "tag-only") {
1136
1269
  await fanOutPaths(payload, req, typed?.slug, `Revalidating deleted ${collectionSlug} at path:`);
1137
1270
  }
@@ -1140,11 +1273,14 @@ function createRevalidateCollectionHook(options) {
1140
1273
  };
1141
1274
  return { afterChange, afterDelete };
1142
1275
  }
1143
- var createRevalidatePageHooks = (opts = {}) => createRevalidateCollectionHook({
1144
- collectionSlug: "pages",
1145
- urlPathPrefix: "",
1146
- ...opts
1147
- });
1276
+ var createRevalidatePageHooks = (opts = {}) => {
1277
+ console.log("[WWW] render/hooks:createRevalidatePageHooks (deprecated alias) opts=", JSON.stringify(opts));
1278
+ return createRevalidateCollectionHook({
1279
+ collectionSlug: "pages",
1280
+ urlPathPrefix: "",
1281
+ ...opts
1282
+ });
1283
+ };
1148
1284
 
1149
1285
  // src/data/collections/StaticPages/index.ts
1150
1286
  var createStaticPagesCollection = (blocks) => {
@@ -1228,9 +1364,27 @@ function createStaticPageExports({
1228
1364
  importMap: importMapArg
1229
1365
  }) {
1230
1366
  const importMap = importMapArg ?? {};
1367
+ let dbgRenderCount = 0;
1231
1368
  const default_ = async () => {
1232
1369
  const { getLocale } = await import("next-intl/server");
1233
1370
  const locale = await getLocale();
1371
+ console.log("[WWW] render/pages:createStaticPageExports:default_ kind=", kind, "locale=", locale);
1372
+ dbgRenderCount++;
1373
+ {
1374
+ let reqUrl = "?";
1375
+ try {
1376
+ const { headers } = await import("next/headers");
1377
+ const h = await headers();
1378
+ reqUrl = h.get("x-invoke-path") || h.get("x-matched-path") || h.get("x-next-url") || h.get("next-url") || h.get("referer") || "?";
1379
+ } catch {}
1380
+ console.error(`[WWW-DBG static-render #${dbgRenderCount}] kind=${kind} locale=${locale} url=${reqUrl}`);
1381
+ if (dbgRenderCount <= 5) {
1382
+ console.error(`[WWW-DBG static-render #${dbgRenderCount}] stack:
1383
+ ` + (new Error("static-render").stack?.split(`
1384
+ `).slice(2, 12).join(`
1385
+ `) ?? ""));
1386
+ }
1387
+ }
1234
1388
  const doc = await queryDocBySlug({
1235
1389
  collectionSlug: STATIC_PAGES_SLUG,
1236
1390
  slug: kind,
@@ -1247,6 +1401,7 @@ function createStaticPageExports({
1247
1401
  });
1248
1402
  }
1249
1403
  const cfg = await configPromise;
1404
+ console.log("[WWW] render/pages:createStaticPageExports:default_ -> rendering via PagesPage kind=", kind, "locale=", locale);
1250
1405
  return /* @__PURE__ */ jsx9(PagesPage, {
1251
1406
  doc,
1252
1407
  locale,
@@ -1264,11 +1419,14 @@ init_PageShowcase();
1264
1419
  import { RichText as RichText2 } from "@payloadcms/richtext-lexical/react";
1265
1420
  import { jsx as jsx10, jsxs as jsxs5, Fragment as Fragment6 } from "react/jsx-runtime";
1266
1421
  async function PostsPage({ doc, locale, importMap: _importMap }) {
1267
- if (!doc)
1422
+ if (!doc) {
1423
+ console.log("[WWW] render/pages:PostsPage no doc");
1268
1424
  return /* @__PURE__ */ jsx10(Fragment6, {});
1425
+ }
1269
1426
  const title = readText(doc.title, locale);
1270
1427
  const excerpt = readText(doc.excerpt, locale);
1271
1428
  const content = doc.content;
1429
+ console.log("[WWW] render/pages:PostsPage titleLen=", title.length, "excerptLen=", excerpt.length, "hasContent=", Boolean(content), "locale=", locale);
1272
1430
  return /* @__PURE__ */ jsxs5("article", {
1273
1431
  className: "posts-page prose prose-neutral dark:prose-invert mx-auto max-w-3xl py-10",
1274
1432
  children: [
@@ -1321,11 +1479,14 @@ function readText(value, preferredLocale) {
1321
1479
  import"server-only";
1322
1480
  import { jsx as jsx11, jsxs as jsxs6, Fragment as Fragment7 } from "react/jsx-runtime";
1323
1481
  function HeaderPage({ data, locale: _locale }) {
1324
- if (!data)
1482
+ if (!data) {
1483
+ console.log("[WWW] render/pages:HeaderPage no data");
1325
1484
  return /* @__PURE__ */ jsx11(Fragment7, {});
1485
+ }
1326
1486
  const nav = data.nav ?? [];
1327
1487
  const items = nav.filter((b) => b.blockType === "navItem");
1328
1488
  const columns = nav.filter((b) => b.blockType === "navColumn");
1489
+ console.log("[WWW] render/pages:HeaderPage items=", items.length, "columns=", columns.length, "locale=", _locale);
1329
1490
  const renderLink = (link, fallbackHref = "#") => {
1330
1491
  if (!link)
1331
1492
  return /* @__PURE__ */ jsx11("a", {
@@ -1379,11 +1540,14 @@ function HeaderPage({ data, locale: _locale }) {
1379
1540
  import"server-only";
1380
1541
  import { jsx as jsx12, jsxs as jsxs7, Fragment as Fragment8 } from "react/jsx-runtime";
1381
1542
  function FooterPage({ data, locale: _locale }) {
1382
- if (!data)
1543
+ if (!data) {
1544
+ console.log("[WWW] render/pages:FooterPage no data");
1383
1545
  return /* @__PURE__ */ jsx12(Fragment8, {});
1546
+ }
1384
1547
  const nav = data.nav ?? [];
1385
1548
  const items = nav.filter((b) => b.blockType === "navItem");
1386
1549
  const columns = nav.filter((b) => b.blockType === "navColumn");
1550
+ console.log("[WWW] render/pages:FooterPage items=", items.length, "columns=", columns.length, "locale=", _locale);
1387
1551
  const renderLink = (link, fallbackHref = "#") => {
1388
1552
  if (!link)
1389
1553
  return /* @__PURE__ */ jsx12("a", {