@justanarthur/payload-www 0.3.3 → 0.3.5
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/dist/blocks.js +6 -2
- package/dist/collections.js +47 -15
- package/dist/components.js +1 -0
- package/dist/config.js +79 -21
- package/dist/core-blocks.js +6 -2
- package/dist/core-utils.js +5 -1
- package/dist/data-collections.js +47 -15
- package/dist/data-test.js +79 -21
- package/dist/globals.js +10 -1
- package/dist/hooks.js +47 -15
- package/dist/index.js +1 -0
- package/dist/metadata.js +64 -21
- package/dist/pages.js +118 -36
- package/dist/render-components.js +13 -3
- package/dist/render-metadata.js +64 -21
- package/dist/render-pages.js +178 -53
- package/dist/render-utils.js +58 -15
- package/dist/server.js +179 -56
- package/dist/test.js +79 -21
- package/dist/utils.js +5 -1
- package/dist/with-www-config.js +79 -21
- package/package.json +1 -1
package/dist/render-pages.js
CHANGED
|
@@ -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",
|
|
@@ -207,13 +209,17 @@ function getFromImportMap(key, importMap) {
|
|
|
207
209
|
import { jsx } from "react/jsx-runtime";
|
|
208
210
|
function renderCollectionModule(collection = [], slug, importMap, props) {
|
|
209
211
|
const renderPath = collection?.find((c) => c.slug === slug)?.custom?.path;
|
|
210
|
-
if (!renderPath)
|
|
212
|
+
if (!renderPath) {
|
|
213
|
+
console.log("[WWW] render/utils:renderCollectionModule no custom.path slug=", slug);
|
|
211
214
|
return null;
|
|
215
|
+
}
|
|
212
216
|
const CollectionRenderModule = getFromImportMap(renderPath, importMap);
|
|
213
217
|
if (!CollectionRenderModule) {
|
|
218
|
+
console.error("[WWW] render/utils:renderCollectionModule not found slug=", slug, "path=", renderPath);
|
|
214
219
|
if (false) {}
|
|
215
220
|
return null;
|
|
216
221
|
}
|
|
222
|
+
console.log("[WWW] render/utils:renderCollectionModule rendering slug=", slug, "path=", renderPath);
|
|
217
223
|
return /* @__PURE__ */ jsx(CollectionRenderModule, {
|
|
218
224
|
importMap,
|
|
219
225
|
...props
|
|
@@ -234,6 +240,7 @@ async function buildHreflangAlternates({
|
|
|
234
240
|
localePrefix = "always"
|
|
235
241
|
}) {
|
|
236
242
|
const allLocaleSlugs = await queryAllLocaleSlugs(storedSlug, locale);
|
|
243
|
+
console.log("[WWW] render/metadata:buildHreflangAlternates storedSlug=", storedSlug, "locale=", locale, "allLocaleSlugs=", JSON.stringify(allLocaleSlugs));
|
|
237
244
|
const languages = {};
|
|
238
245
|
const urlFor = (l, slug) => {
|
|
239
246
|
const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
|
|
@@ -251,6 +258,7 @@ async function buildHreflangAlternates({
|
|
|
251
258
|
if (allLocaleSlugs?.[defaultLocale]) {
|
|
252
259
|
languages["x-default"] = urlFor(defaultLocale, allLocaleSlugs[defaultLocale]);
|
|
253
260
|
}
|
|
261
|
+
console.log("[WWW] render/metadata:buildHreflangAlternates ->", JSON.stringify(languages));
|
|
254
262
|
return languages;
|
|
255
263
|
}
|
|
256
264
|
|
|
@@ -265,6 +273,11 @@ function getImageUrl(doc, siteUrl) {
|
|
|
265
273
|
return img.url.startsWith("http") ? img.url : `${siteUrl}${img.url}`;
|
|
266
274
|
return null;
|
|
267
275
|
}
|
|
276
|
+
function getImageUrlWithLog(doc, siteUrl) {
|
|
277
|
+
const result = getImageUrl(doc, siteUrl);
|
|
278
|
+
console.log("[WWW] render/metadata:jsonld:getImageUrl ->", result);
|
|
279
|
+
return result;
|
|
280
|
+
}
|
|
268
281
|
function resolveLocalizedField(value, locale) {
|
|
269
282
|
if (value == null)
|
|
270
283
|
return "";
|
|
@@ -286,6 +299,13 @@ function resolveLocalizedField(value, locale) {
|
|
|
286
299
|
}
|
|
287
300
|
return Object.values(obj).filter((v) => typeof v === "string" && v.length > 0).join(" / ");
|
|
288
301
|
}
|
|
302
|
+
function resolveLocalizedFieldWithLog(value, locale) {
|
|
303
|
+
const result = resolveLocalizedField(value, locale);
|
|
304
|
+
if (value && typeof value === "object") {
|
|
305
|
+
console.log("[WWW] render/metadata:jsonld:resolveLocalizedField locale=", locale, "->", JSON.stringify(result));
|
|
306
|
+
}
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
289
309
|
function buildArticleLd({
|
|
290
310
|
doc,
|
|
291
311
|
url,
|
|
@@ -296,12 +316,13 @@ function buildArticleLd({
|
|
|
296
316
|
publisherLogo
|
|
297
317
|
}) {
|
|
298
318
|
const name = publisherName ?? new URL(siteUrl).hostname;
|
|
319
|
+
console.log("[WWW] render/metadata:buildArticleLd url=", url, "locale=", locale, "type=", type, "publisherName=", name);
|
|
299
320
|
const ld = {
|
|
300
321
|
"@context": "https://schema.org",
|
|
301
322
|
"@type": type,
|
|
302
323
|
"@id": `${url}#article`,
|
|
303
|
-
headline:
|
|
304
|
-
description:
|
|
324
|
+
headline: resolveLocalizedFieldWithLog(doc.title, locale),
|
|
325
|
+
description: resolveLocalizedFieldWithLog(doc.meta?.description ?? doc.description ?? doc.excerpt, locale),
|
|
305
326
|
inLanguage: locale,
|
|
306
327
|
url,
|
|
307
328
|
dateModified: doc.updatedAt ? new Date(doc.updatedAt).toISOString() : undefined
|
|
@@ -309,7 +330,7 @@ function buildArticleLd({
|
|
|
309
330
|
const datePublished = doc.publishedAt ?? doc.createdAt;
|
|
310
331
|
if (datePublished)
|
|
311
332
|
ld.datePublished = new Date(datePublished).toISOString();
|
|
312
|
-
const imgUrl =
|
|
333
|
+
const imgUrl = getImageUrlWithLog(doc, siteUrl);
|
|
313
334
|
if (imgUrl)
|
|
314
335
|
ld.image = imgUrl;
|
|
315
336
|
ld.author = { "@type": "Organization", name, url: siteUrl };
|
|
@@ -325,6 +346,7 @@ function buildBreadcrumbsLd({
|
|
|
325
346
|
items,
|
|
326
347
|
currentUrl
|
|
327
348
|
}) {
|
|
349
|
+
console.log("[WWW] render/metadata:buildBreadcrumbsLd items=", items.length, "currentUrl=", currentUrl);
|
|
328
350
|
return {
|
|
329
351
|
"@context": "https://schema.org",
|
|
330
352
|
"@type": "BreadcrumbList",
|
|
@@ -342,6 +364,7 @@ function buildOrganizationLd({
|
|
|
342
364
|
logo,
|
|
343
365
|
sameAs
|
|
344
366
|
}) {
|
|
367
|
+
console.log("[WWW] render/metadata:buildOrganizationLd siteUrl=", siteUrl, "name=", name, "logo?", Boolean(logo), "sameAs?", Boolean(sameAs));
|
|
345
368
|
const org = {
|
|
346
369
|
"@context": "https://schema.org",
|
|
347
370
|
"@type": "Organization",
|
|
@@ -357,23 +380,29 @@ function buildOrganizationLd({
|
|
|
357
380
|
// src/render/metadata/slug.ts
|
|
358
381
|
var SLUG_NESTED_DIVIDER = "_";
|
|
359
382
|
function segmentsToStoredSlug(segments, nested) {
|
|
360
|
-
if (!Array.isArray(segments))
|
|
383
|
+
if (!Array.isArray(segments)) {
|
|
384
|
+
console.log("[WWW] render/metadata:segmentsToStoredSlug string passthrough:", JSON.stringify(segments));
|
|
361
385
|
return segments;
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
386
|
+
}
|
|
387
|
+
const result = nested ? segments.join(SLUG_NESTED_DIVIDER) : segments[0] ?? "";
|
|
388
|
+
console.log("[WWW] render/metadata:segmentsToStoredSlug nested=", nested, "segments=", JSON.stringify(segments), "->", result);
|
|
389
|
+
return result;
|
|
365
390
|
}
|
|
366
391
|
function segmentsToUrlPath(segments, nested) {
|
|
392
|
+
let result;
|
|
367
393
|
if (!Array.isArray(segments))
|
|
368
|
-
|
|
369
|
-
if (nested)
|
|
370
|
-
|
|
371
|
-
|
|
394
|
+
result = "/" + segments;
|
|
395
|
+
else if (nested)
|
|
396
|
+
result = "/" + segments.join("/");
|
|
397
|
+
else
|
|
398
|
+
result = "/" + (segments[0] ?? "");
|
|
399
|
+
console.log("[WWW] render/metadata:segmentsToUrlPath nested=", nested, "segments=", JSON.stringify(segments), "->", result);
|
|
400
|
+
return result;
|
|
372
401
|
}
|
|
373
402
|
function storedSlugToSegments(storedSlug, nested) {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
return
|
|
403
|
+
const result = nested ? storedSlug.split(SLUG_NESTED_DIVIDER) : storedSlug;
|
|
404
|
+
console.log("[WWW] render/metadata:storedSlugToSegments nested=", nested, "storedSlug=", storedSlug, "->", JSON.stringify(result));
|
|
405
|
+
return result;
|
|
377
406
|
}
|
|
378
407
|
function buildCanonicalUrl({
|
|
379
408
|
siteUrl,
|
|
@@ -383,7 +412,9 @@ function buildCanonicalUrl({
|
|
|
383
412
|
}) {
|
|
384
413
|
const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
|
|
385
414
|
const prefixSegment = trimmedPrefix ? `/${trimmedPrefix}` : "";
|
|
386
|
-
|
|
415
|
+
const result = `${siteUrl}/${locale}${prefixSegment}${urlPath}`;
|
|
416
|
+
console.log("[WWW] render/metadata:buildCanonicalUrl siteUrl=", siteUrl, "locale=", locale, "urlPrefix=", urlPrefix, "urlPath=", urlPath, "->", result);
|
|
417
|
+
return result;
|
|
387
418
|
}
|
|
388
419
|
function getUrlPath(segments, nested, homeSlug) {
|
|
389
420
|
const urlPath = segmentsToUrlPath(segments, nested);
|
|
@@ -409,6 +440,7 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
|
|
|
409
440
|
draft = false,
|
|
410
441
|
config
|
|
411
442
|
}) {
|
|
443
|
+
console.log("[WWW] render/metadata:queryDocBySlug collection=", collectionSlug, "slug=", slug, "slugField=", slugField, "locale=", locale, "draft=", draft);
|
|
412
444
|
const payload = await getPayload({ config });
|
|
413
445
|
const result = await payload.find({
|
|
414
446
|
collection: collectionSlug,
|
|
@@ -419,7 +451,9 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
|
|
|
419
451
|
where: { [slugField]: { equals: slug } },
|
|
420
452
|
locale
|
|
421
453
|
});
|
|
422
|
-
|
|
454
|
+
const doc = result.docs?.[0] ?? null;
|
|
455
|
+
console.log("[WWW] render/metadata:queryDocBySlug ->", doc ? "hit" : "miss");
|
|
456
|
+
return doc;
|
|
423
457
|
});
|
|
424
458
|
var queryAllDocs = cache(async function queryAllDocs2({
|
|
425
459
|
collectionSlug,
|
|
@@ -427,6 +461,7 @@ var queryAllDocs = cache(async function queryAllDocs2({
|
|
|
427
461
|
locale,
|
|
428
462
|
config
|
|
429
463
|
}) {
|
|
464
|
+
console.log("[WWW] render/metadata:queryAllDocs collection=", collectionSlug, "locale=", locale);
|
|
430
465
|
const payload = await getPayload({ config });
|
|
431
466
|
const result = await payload.find({
|
|
432
467
|
collection: collectionSlug,
|
|
@@ -437,7 +472,9 @@ var queryAllDocs = cache(async function queryAllDocs2({
|
|
|
437
472
|
select: { [slugField]: true },
|
|
438
473
|
locale
|
|
439
474
|
});
|
|
440
|
-
|
|
475
|
+
const docs = result.docs ?? [];
|
|
476
|
+
console.log("[WWW] render/metadata:queryAllDocs -> count=", docs.length);
|
|
477
|
+
return docs;
|
|
441
478
|
});
|
|
442
479
|
var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
443
480
|
collectionSlug,
|
|
@@ -446,6 +483,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
446
483
|
locale,
|
|
447
484
|
config
|
|
448
485
|
}) {
|
|
486
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs collection=", collectionSlug, "slug=", slug, "locale=", locale);
|
|
449
487
|
const payload = await getPayload({ config });
|
|
450
488
|
const result = await payload.find({
|
|
451
489
|
collection: collectionSlug,
|
|
@@ -458,8 +496,10 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
458
496
|
select: { [slugField]: true }
|
|
459
497
|
});
|
|
460
498
|
const doc = result.docs?.[0];
|
|
461
|
-
if (!doc)
|
|
499
|
+
if (!doc) {
|
|
500
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> undefined (no doc)");
|
|
462
501
|
return;
|
|
502
|
+
}
|
|
463
503
|
let fieldValue = doc[slugField];
|
|
464
504
|
if (doc.id != null) {
|
|
465
505
|
const allLocales = await payload.findByID({
|
|
@@ -474,6 +514,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
474
514
|
fieldValue = allLocales[slugField];
|
|
475
515
|
}
|
|
476
516
|
if (fieldValue && typeof fieldValue === "object") {
|
|
517
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> localized map=", JSON.stringify(fieldValue));
|
|
477
518
|
return fieldValue;
|
|
478
519
|
}
|
|
479
520
|
const resolved = await config;
|
|
@@ -481,6 +522,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
481
522
|
const out = {};
|
|
482
523
|
for (const l of rawLocales)
|
|
483
524
|
out[l] = String(fieldValue ?? slug);
|
|
525
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> flat-fanout locales=", rawLocales.length, "slug=", JSON.stringify(fieldValue ?? slug));
|
|
484
526
|
return out;
|
|
485
527
|
});
|
|
486
528
|
var queryGlobal = cache(async function queryGlobal2({
|
|
@@ -490,6 +532,7 @@ var queryGlobal = cache(async function queryGlobal2({
|
|
|
490
532
|
draft = false,
|
|
491
533
|
config
|
|
492
534
|
}) {
|
|
535
|
+
console.log("[WWW] render/metadata:queryGlobal global=", globalSlug, "locale=", locale, "depth=", depth, "draft=", draft);
|
|
493
536
|
const payload = await getPayload({ config });
|
|
494
537
|
try {
|
|
495
538
|
const global = await payload.findGlobal({
|
|
@@ -498,17 +541,23 @@ var queryGlobal = cache(async function queryGlobal2({
|
|
|
498
541
|
draft,
|
|
499
542
|
locale
|
|
500
543
|
});
|
|
544
|
+
console.log("[WWW] render/metadata:queryGlobal -> hit");
|
|
501
545
|
return global;
|
|
502
|
-
} catch {
|
|
546
|
+
} catch (error) {
|
|
547
|
+
console.warn("[WWW] render/metadata:queryGlobal failed for slug=", globalSlug, "err=", String(error));
|
|
503
548
|
return null;
|
|
504
549
|
}
|
|
505
550
|
});
|
|
506
551
|
function getRenderModuleExports(exportName, collection, importMap) {
|
|
507
552
|
const path = collection?.custom?.path;
|
|
508
|
-
if (!path)
|
|
553
|
+
if (!path) {
|
|
554
|
+
console.log("[WWW] render/metadata:getRenderModuleExports no custom.path exportName=", exportName);
|
|
509
555
|
return;
|
|
556
|
+
}
|
|
510
557
|
const mod = getFromImportMap(path, importMap);
|
|
511
|
-
|
|
558
|
+
const value = mod?.[exportName];
|
|
559
|
+
console.log("[WWW] render/metadata:getRenderModuleExports exportName=", exportName, "path=", path, "hit=", Boolean(value));
|
|
560
|
+
return value;
|
|
512
561
|
}
|
|
513
562
|
|
|
514
563
|
// src/render/pages/createCollectionPageExports.tsx
|
|
@@ -536,8 +585,11 @@ var RenderBlocks = ({
|
|
|
536
585
|
locale,
|
|
537
586
|
searchParams
|
|
538
587
|
}) => {
|
|
539
|
-
if (!blocks || !Array.isArray(blocks) || blocks.length === 0)
|
|
588
|
+
if (!blocks || !Array.isArray(blocks) || blocks.length === 0) {
|
|
589
|
+
console.log("[WWW] render/blocks:RenderBlocks no blocks (locale=", locale, ")");
|
|
540
590
|
return null;
|
|
591
|
+
}
|
|
592
|
+
console.log("[WWW] render/blocks:RenderBlocks rendering count=", blocks.length, "locale=", locale);
|
|
541
593
|
const rendered = [];
|
|
542
594
|
for (let i = 0;i < blocks.length; i++) {
|
|
543
595
|
const block = blocks[i];
|
|
@@ -545,9 +597,10 @@ var RenderBlocks = ({
|
|
|
545
597
|
const importMapPath = config.admin?.dependencies?.[blockType]?.path ?? generateImportName("block", blockType);
|
|
546
598
|
const Block = getFromImportMap(importMapPath, importMap);
|
|
547
599
|
if (!Block) {
|
|
548
|
-
console.warn(`
|
|
600
|
+
console.warn(`[WWW] render/blocks:RenderBlocks no block for type=${blockType} importMapPath=${importMapPath} (locale=${locale})`);
|
|
549
601
|
continue;
|
|
550
602
|
}
|
|
603
|
+
console.log("[WWW] render/blocks:RenderBlocks [", i, "] blockType=", blockType, "importMapPath=", importMapPath);
|
|
551
604
|
rendered.push(/* @__PURE__ */ jsx2(Block, {
|
|
552
605
|
index: i,
|
|
553
606
|
...blockProps,
|
|
@@ -564,9 +617,12 @@ var RenderBlocks = ({
|
|
|
564
617
|
// src/render/pages/PagesPage.tsx
|
|
565
618
|
import { jsx as jsx3, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
566
619
|
async function PagesPage({ doc, ...props }) {
|
|
567
|
-
if (!doc)
|
|
620
|
+
if (!doc) {
|
|
621
|
+
console.log("[WWW] render/pages:PagesPage no doc");
|
|
568
622
|
return /* @__PURE__ */ jsx3(Fragment2, {});
|
|
623
|
+
}
|
|
569
624
|
const blocks = doc.blocks ?? [];
|
|
625
|
+
console.log("[WWW] render/pages:PagesPage blocks=", blocks.length, "locale=", props.locale);
|
|
570
626
|
return /* @__PURE__ */ jsx3(Fragment2, {
|
|
571
627
|
children: /* @__PURE__ */ jsx3(RenderBlocks, {
|
|
572
628
|
blocks,
|
|
@@ -604,11 +660,15 @@ function createCollectionPageExports({
|
|
|
604
660
|
const localePrefixMode = typeof routing.localePrefix === "string" ? routing.localePrefix : routing.localePrefix?.mode ?? "always";
|
|
605
661
|
const buildLocalePath = (locale, storedSlug) => {
|
|
606
662
|
const urlPath = getUrlPath(storedSlugToSegments(storedSlug, nested), nested, HOME_SLUG);
|
|
663
|
+
let result;
|
|
607
664
|
if (localePrefixMode === "never")
|
|
608
|
-
|
|
609
|
-
if (localePrefixMode === "as-needed" && locale === defaultLocale)
|
|
610
|
-
|
|
611
|
-
|
|
665
|
+
result = urlPath;
|
|
666
|
+
else if (localePrefixMode === "as-needed" && locale === defaultLocale)
|
|
667
|
+
result = urlPath;
|
|
668
|
+
else
|
|
669
|
+
result = `/${locale}${urlPath}`;
|
|
670
|
+
console.log("[WWW] render/pages:createCollectionPageExports:buildLocalePath locale=", locale, "storedSlug=", storedSlug, "->", result);
|
|
671
|
+
return result;
|
|
612
672
|
};
|
|
613
673
|
async function fetchDoc(locale, storedSlug, draft = false) {
|
|
614
674
|
return queryDocBySlug({
|
|
@@ -639,14 +699,16 @@ function createCollectionPageExports({
|
|
|
639
699
|
for (const [key, url] of Object.entries(languages)) {
|
|
640
700
|
alternates[key] = url;
|
|
641
701
|
}
|
|
702
|
+
console.log("[WWW] render/pages:createCollectionPageExports:resolveHreflangAlternates canonical=", canonical, "alts=", JSON.stringify(alternates));
|
|
642
703
|
return { alternates, canonical };
|
|
643
704
|
}
|
|
644
705
|
const default_ = async (props) => {
|
|
645
706
|
const { slug: rawSlugSegments, locale: incomingLocale } = await props.params ?? {};
|
|
646
707
|
const slugSegments = Array.isArray(rawSlugSegments) ? rawSlugSegments : [];
|
|
647
708
|
const locale = typeof incomingLocale === "string" ? incomingLocale : defaultLocale;
|
|
709
|
+
console.log("[WWW] render/pages:createCollectionPageExports:default_ collectionSlug=", slug, "locale=", locale, "segments=", JSON.stringify(slugSegments), "showcase=", showcaseEnabled);
|
|
648
710
|
if (!locales.includes(locale)) {
|
|
649
|
-
console.error(`[WWW
|
|
711
|
+
console.error(`[WWW] render/pages:createCollectionPageExports:default_ notFound invalid-locale collection=${slug} locale=${locale} segments=${JSON.stringify(slugSegments)}`);
|
|
650
712
|
const { notFound } = await import("next/navigation");
|
|
651
713
|
notFound();
|
|
652
714
|
}
|
|
@@ -654,16 +716,18 @@ function createCollectionPageExports({
|
|
|
654
716
|
setRequestLocale(locale);
|
|
655
717
|
const { draftMode } = await import("next/headers");
|
|
656
718
|
const { isEnabled: draft } = await draftMode();
|
|
719
|
+
console.log("[WWW] render/pages:createCollectionPageExports:default_ draftMode=", draft);
|
|
657
720
|
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
658
721
|
const doc = await fetchDoc(locale, storedSlug, draft);
|
|
659
722
|
if (!doc) {
|
|
660
|
-
console.error(`[WWW
|
|
723
|
+
console.error(`[WWW] render/pages:createCollectionPageExports:default_ notFound no-doc collection=${slug} locale=${locale} storedSlug="${storedSlug}" segments=${JSON.stringify(slugSegments)} draft=${draft}`);
|
|
661
724
|
const { notFound } = await import("next/navigation");
|
|
662
725
|
notFound();
|
|
663
726
|
}
|
|
664
727
|
const cfg = await configPromise;
|
|
665
728
|
const collectionCustomPath = cfg.collections.find((c) => c.slug === slug)?.custom?.path;
|
|
666
729
|
const effectivePath = renderPath ?? collectionCustomPath ?? defaultRenderPath;
|
|
730
|
+
console.log("[WWW] render/pages:createCollectionPageExports:default_ effectivePath=", effectivePath);
|
|
667
731
|
const render = effectivePath === PAGES_RENDER_PATH ? /* @__PURE__ */ jsx6(PagesPage, {
|
|
668
732
|
doc,
|
|
669
733
|
importMap,
|
|
@@ -725,15 +789,22 @@ function createCollectionPageExports({
|
|
|
725
789
|
const { slug: rawSlugSegments, locale: incomingLocale } = await props.params ?? {};
|
|
726
790
|
const slugSegments = Array.isArray(rawSlugSegments) ? rawSlugSegments : [];
|
|
727
791
|
const locale = typeof incomingLocale === "string" ? incomingLocale : defaultLocale;
|
|
728
|
-
|
|
792
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateMetadata collectionSlug=", slug, "locale=", locale, "segments=", JSON.stringify(slugSegments));
|
|
793
|
+
if (!locales.includes(locale)) {
|
|
794
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateMetadata invalid locale -> not found meta");
|
|
729
795
|
return { title: "Not found", robots: { index: false, follow: false } };
|
|
796
|
+
}
|
|
730
797
|
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
731
798
|
const doc = await fetchDoc(locale, storedSlug);
|
|
732
|
-
if (!doc)
|
|
799
|
+
if (!doc) {
|
|
800
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateMetadata no doc -> not found meta");
|
|
733
801
|
return { title: "Not found", robots: { index: false, follow: false } };
|
|
802
|
+
}
|
|
734
803
|
const collection = cfg.collections.find((c) => c.slug === slug);
|
|
735
|
-
if (!collection)
|
|
804
|
+
if (!collection) {
|
|
805
|
+
console.warn("[WWW] render/pages:createCollectionPageExports:generateMetadata collection not in config slug=", slug);
|
|
736
806
|
return {};
|
|
807
|
+
}
|
|
737
808
|
const { canonical, alternates } = await resolveHreflangAlternates(locale, storedSlug);
|
|
738
809
|
const meta = await generateMeta({
|
|
739
810
|
doc,
|
|
@@ -755,6 +826,7 @@ function createCollectionPageExports({
|
|
|
755
826
|
const urlPath = buildLocalePath(locale, storedSlug);
|
|
756
827
|
const canonical = `${siteUrl}${urlPath}`;
|
|
757
828
|
const entries = Array.isArray(jsonLdOption) ? jsonLdOption : metadataType === "article" ? [{ type: "article" }] : [{ type: "website" }];
|
|
829
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateJsonLd collection=", slug, "locale=", locale, "entries=", entries.map((e) => e.type).join(","));
|
|
758
830
|
const outputs = [];
|
|
759
831
|
for (const entry of entries) {
|
|
760
832
|
const id = entry.id ?? `jsonld-${entry.type}-${outputs.length}`;
|
|
@@ -815,6 +887,7 @@ function createCollectionPageExports({
|
|
|
815
887
|
return outputs;
|
|
816
888
|
}
|
|
817
889
|
async function generateStaticParams() {
|
|
890
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateStaticParams collection=", slug, "locales=", JSON.stringify(locales));
|
|
818
891
|
const params = [];
|
|
819
892
|
for (const locale of locales) {
|
|
820
893
|
const docs = await queryAllDocs({ collectionSlug: slug, slugField: "slug", locale, config: configPromise });
|
|
@@ -826,9 +899,11 @@ function createCollectionPageExports({
|
|
|
826
899
|
params.push({ slug: Array.isArray(segments) ? segments : [segments], locale });
|
|
827
900
|
}
|
|
828
901
|
}
|
|
902
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateStaticParams -> count=", params.length);
|
|
829
903
|
return params;
|
|
830
904
|
}
|
|
831
905
|
async function generateSitemap() {
|
|
906
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateSitemap collection=", slug, "locales=", JSON.stringify(locales));
|
|
832
907
|
const docs = await queryAllDocs({
|
|
833
908
|
collectionSlug: slug,
|
|
834
909
|
slugField: "slug",
|
|
@@ -848,6 +923,7 @@ function createCollectionPageExports({
|
|
|
848
923
|
urls.push({ url: `${siteUrl}${urlPath}`, lastModified: lastmod, changeFrequency: changefreq, priority });
|
|
849
924
|
}
|
|
850
925
|
}
|
|
926
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateSitemap -> urls=", urls.length);
|
|
851
927
|
return urls;
|
|
852
928
|
}
|
|
853
929
|
return {
|
|
@@ -903,13 +979,17 @@ import"server-only";
|
|
|
903
979
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
904
980
|
function renderGlobalModule(globals = [], slug, importMap, props) {
|
|
905
981
|
const renderPath = globals?.find((g) => g.slug === slug)?.custom?.path;
|
|
906
|
-
if (!renderPath)
|
|
982
|
+
if (!renderPath) {
|
|
983
|
+
console.log("[WWW] render/utils:renderGlobalModule no custom.path slug=", slug);
|
|
907
984
|
return null;
|
|
985
|
+
}
|
|
908
986
|
const GlobalRenderModule = getFromImportMap(renderPath, importMap);
|
|
909
987
|
if (!GlobalRenderModule) {
|
|
988
|
+
console.error("[WWW] render/utils:renderGlobalModule not found slug=", slug, "path=", renderPath);
|
|
910
989
|
if (false) {}
|
|
911
990
|
return null;
|
|
912
991
|
}
|
|
992
|
+
console.log("[WWW] render/utils:renderGlobalModule rendering slug=", slug, "path=", renderPath);
|
|
913
993
|
return /* @__PURE__ */ jsx7(GlobalRenderModule, {
|
|
914
994
|
importMap,
|
|
915
995
|
...props
|
|
@@ -925,7 +1005,9 @@ function createRootLayoutExports(args) {
|
|
|
925
1005
|
params
|
|
926
1006
|
}) {
|
|
927
1007
|
const { locale } = await params;
|
|
1008
|
+
console.log("[WWW] render/pages:createRootLayoutExports:RootLayout locale=", locale);
|
|
928
1009
|
if (!routing.locales.includes(locale)) {
|
|
1010
|
+
console.error("[WWW] render/pages:createRootLayoutExports:RootLayout invalid locale=", locale);
|
|
929
1011
|
const { notFound } = await import("next/navigation");
|
|
930
1012
|
notFound();
|
|
931
1013
|
}
|
|
@@ -934,11 +1016,13 @@ function createRootLayoutExports(args) {
|
|
|
934
1016
|
const messages = await getMessages();
|
|
935
1017
|
const { draftMode: nextDraftMode } = await import("next/headers");
|
|
936
1018
|
const { isEnabled: draftMode } = await nextDraftMode();
|
|
1019
|
+
console.log("[WWW] render/pages:createRootLayoutExports:RootLayout draftMode=", draftMode);
|
|
937
1020
|
const cfg = await configPromise;
|
|
938
1021
|
const [headerData, footerData] = await Promise.all([
|
|
939
1022
|
queryGlobal({ globalSlug: "header", locale, depth: 0, config: configPromise }),
|
|
940
1023
|
queryGlobal({ globalSlug: "footer", locale, depth: 0, config: configPromise })
|
|
941
1024
|
]);
|
|
1025
|
+
console.log("[WWW] render/pages:createRootLayoutExports:RootLayout header?", Boolean(headerData), "footer?", Boolean(footerData));
|
|
942
1026
|
const headerEl = renderGlobalModule(cfg.globals, "header", importMap, {
|
|
943
1027
|
data: headerData,
|
|
944
1028
|
locale
|
|
@@ -997,30 +1081,45 @@ var authenticatedOrPublished = ({ req: { user } }) => {
|
|
|
997
1081
|
|
|
998
1082
|
// src/render/_locale.ts
|
|
999
1083
|
function prefixFor(locale, defaultLocale, mode) {
|
|
1084
|
+
let result;
|
|
1000
1085
|
if (mode === "never")
|
|
1001
|
-
|
|
1002
|
-
if (mode === "as-needed" && locale === defaultLocale)
|
|
1003
|
-
|
|
1004
|
-
|
|
1086
|
+
result = "";
|
|
1087
|
+
else if (mode === "as-needed" && locale === defaultLocale)
|
|
1088
|
+
result = "";
|
|
1089
|
+
else
|
|
1090
|
+
result = `/${locale}`;
|
|
1091
|
+
console.log("[WWW] render/_locale:prefixFor locale=", locale, "default=", defaultLocale, "mode=", mode, "->", JSON.stringify(result));
|
|
1092
|
+
return result;
|
|
1005
1093
|
}
|
|
1006
1094
|
function resolveLocale(req) {
|
|
1007
|
-
if (!req || typeof req !== "object")
|
|
1095
|
+
if (!req || typeof req !== "object") {
|
|
1096
|
+
console.log('[WWW] render/_locale:resolveLocale -> "" (no req)');
|
|
1008
1097
|
return "";
|
|
1098
|
+
}
|
|
1009
1099
|
const r = req;
|
|
1010
|
-
if (typeof r.locale === "string" && r.locale.length > 0)
|
|
1100
|
+
if (typeof r.locale === "string" && r.locale.length > 0) {
|
|
1101
|
+
console.log("[WWW] render/_locale:resolveLocale ->", r.locale, "(from req.locale)");
|
|
1011
1102
|
return r.locale;
|
|
1103
|
+
}
|
|
1012
1104
|
const fallback = r.payload?.config?.localization?.defaultLocale;
|
|
1013
|
-
if (typeof fallback === "string" && fallback.length > 0)
|
|
1105
|
+
if (typeof fallback === "string" && fallback.length > 0) {
|
|
1106
|
+
console.log("[WWW] render/_locale:resolveLocale ->", fallback, "(from config.localization.defaultLocale)");
|
|
1014
1107
|
return fallback;
|
|
1108
|
+
}
|
|
1109
|
+
console.log('[WWW] render/_locale:resolveLocale -> "" (no locale anywhere)');
|
|
1015
1110
|
return "";
|
|
1016
1111
|
}
|
|
1017
1112
|
function allLocales(req) {
|
|
1018
|
-
if (!req || typeof req !== "object")
|
|
1113
|
+
if (!req || typeof req !== "object") {
|
|
1114
|
+
console.log("[WWW] render/_locale:allLocales -> [] (no req)");
|
|
1019
1115
|
return [];
|
|
1116
|
+
}
|
|
1020
1117
|
const r = req;
|
|
1021
1118
|
const list = r.payload?.config?.localization?.locales;
|
|
1022
|
-
if (!Array.isArray(list) || list.length === 0)
|
|
1119
|
+
if (!Array.isArray(list) || list.length === 0) {
|
|
1120
|
+
console.log("[WWW] render/_locale:allLocales -> [] (no locales declared)");
|
|
1023
1121
|
return [];
|
|
1122
|
+
}
|
|
1024
1123
|
const out = [];
|
|
1025
1124
|
for (const entry of list) {
|
|
1026
1125
|
if (typeof entry === "string" && entry.length > 0) {
|
|
@@ -1031,6 +1130,7 @@ function allLocales(req) {
|
|
|
1031
1130
|
out.push(code);
|
|
1032
1131
|
}
|
|
1033
1132
|
}
|
|
1133
|
+
console.log("[WWW] render/_locale:allLocales ->", JSON.stringify(out));
|
|
1034
1134
|
return out;
|
|
1035
1135
|
}
|
|
1036
1136
|
|
|
@@ -1040,21 +1140,28 @@ function nextCacheImport() {
|
|
|
1040
1140
|
return cachePromise ??= import("next/cache");
|
|
1041
1141
|
}
|
|
1042
1142
|
function shouldSkipRevalidate(context) {
|
|
1043
|
-
|
|
1143
|
+
const skip = Boolean(context?.disableRevalidate);
|
|
1144
|
+
if (skip)
|
|
1145
|
+
console.log("[WWW] render/hooks:_shared:shouldSkipRevalidate -> skip");
|
|
1146
|
+
return skip;
|
|
1044
1147
|
}
|
|
1045
1148
|
async function safeRevalidatePath(payload, path) {
|
|
1149
|
+
console.log("[WWW] render/hooks:_shared:safeRevalidatePath path=", path);
|
|
1046
1150
|
try {
|
|
1047
1151
|
const { revalidatePath } = await nextCacheImport();
|
|
1048
1152
|
revalidatePath(path);
|
|
1049
1153
|
} catch (error) {
|
|
1154
|
+
console.error("[WWW] render/hooks:_shared:safeRevalidatePath failed path=", path, "err=", String(error));
|
|
1050
1155
|
payload.logger.error(`revalidatePath("${path}") failed: ${String(error)}`);
|
|
1051
1156
|
}
|
|
1052
1157
|
}
|
|
1053
1158
|
async function safeRevalidateTag(payload, tag, profile = "max") {
|
|
1159
|
+
console.log("[WWW] render/hooks:_shared:safeRevalidateTag tag=", tag, "profile=", profile);
|
|
1054
1160
|
try {
|
|
1055
1161
|
const { revalidateTag } = await nextCacheImport();
|
|
1056
1162
|
revalidateTag(tag, profile);
|
|
1057
1163
|
} catch (error) {
|
|
1164
|
+
console.error("[WWW] render/hooks:_shared:safeRevalidateTag failed tag=", tag, "err=", String(error));
|
|
1058
1165
|
payload.logger.error(`revalidateTag("${tag}") failed: ${String(error)}`);
|
|
1059
1166
|
}
|
|
1060
1167
|
}
|
|
@@ -1070,6 +1177,7 @@ function createRevalidateCollectionHook(options) {
|
|
|
1070
1177
|
pathMode = "url"
|
|
1071
1178
|
} = options;
|
|
1072
1179
|
const resolvedSitemapTag = sitemapTag === false ? false : sitemapTag ?? `${collectionSlug}-sitemap`;
|
|
1180
|
+
console.log("[WWW] render/hooks:createRevalidateCollectionHook collectionSlug=", collectionSlug, "urlPathPrefix=", urlPathPrefix, "sitemapTag=", resolvedSitemapTag, "pathMode=", pathMode);
|
|
1073
1181
|
const resolveDefaults = (req) => {
|
|
1074
1182
|
const mode = modeOption ?? "always";
|
|
1075
1183
|
const defaultLocale = defaultLocaleOption ?? req?.payload?.config?.localization?.defaultLocale ?? "";
|
|
@@ -1098,6 +1206,7 @@ function createRevalidateCollectionHook(options) {
|
|
|
1098
1206
|
}
|
|
1099
1207
|
};
|
|
1100
1208
|
const fireCollectionTags = async (payload, docId, req) => {
|
|
1209
|
+
console.log("[WWW] render/hooks:fireCollectionTags collectionSlug=", collectionSlug, "docId=", docId);
|
|
1101
1210
|
if (typeof docId === "string" || typeof docId === "number") {
|
|
1102
1211
|
await safeRevalidateTag(payload, `collection_${collectionSlug}_${docId}`);
|
|
1103
1212
|
}
|
|
@@ -1111,6 +1220,7 @@ function createRevalidateCollectionHook(options) {
|
|
|
1111
1220
|
const { payload } = req;
|
|
1112
1221
|
const typed = doc;
|
|
1113
1222
|
const prev = previousDoc;
|
|
1223
|
+
console.log("[WWW] render/hooks:afterChange collectionSlug=", collectionSlug, "id=", typed.id, "slug=", typed.slug, "prevSlug=", prev?.slug);
|
|
1114
1224
|
const isPublished = typed._status === "published";
|
|
1115
1225
|
const wasPublished = prev?._status === "published";
|
|
1116
1226
|
const prevSlugIsString = typeof prev?.slug === "string";
|
|
@@ -1134,6 +1244,7 @@ function createRevalidateCollectionHook(options) {
|
|
|
1134
1244
|
return doc ?? null;
|
|
1135
1245
|
const { payload } = req;
|
|
1136
1246
|
const typed = doc;
|
|
1247
|
+
console.log("[WWW] render/hooks:afterDelete collectionSlug=", collectionSlug, "id=", typed?.id, "slug=", typed?.slug);
|
|
1137
1248
|
if (pathMode !== "tag-only") {
|
|
1138
1249
|
await fanOutPaths(payload, req, typed?.slug, `Revalidating deleted ${collectionSlug} at path:`);
|
|
1139
1250
|
}
|
|
@@ -1142,11 +1253,14 @@ function createRevalidateCollectionHook(options) {
|
|
|
1142
1253
|
};
|
|
1143
1254
|
return { afterChange, afterDelete };
|
|
1144
1255
|
}
|
|
1145
|
-
var createRevalidatePageHooks = (opts = {}) =>
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1256
|
+
var createRevalidatePageHooks = (opts = {}) => {
|
|
1257
|
+
console.log("[WWW] render/hooks:createRevalidatePageHooks (deprecated alias) opts=", JSON.stringify(opts));
|
|
1258
|
+
return createRevalidateCollectionHook({
|
|
1259
|
+
collectionSlug: "pages",
|
|
1260
|
+
urlPathPrefix: "",
|
|
1261
|
+
...opts
|
|
1262
|
+
});
|
|
1263
|
+
};
|
|
1150
1264
|
|
|
1151
1265
|
// src/data/collections/StaticPages/index.ts
|
|
1152
1266
|
var createStaticPagesCollection = (blocks) => {
|
|
@@ -1234,6 +1348,7 @@ function createStaticPageExports({
|
|
|
1234
1348
|
const default_ = async () => {
|
|
1235
1349
|
const { getLocale } = await import("next-intl/server");
|
|
1236
1350
|
const locale = await getLocale();
|
|
1351
|
+
console.log("[WWW] render/pages:createStaticPageExports:default_ kind=", kind, "locale=", locale);
|
|
1237
1352
|
dbgRenderCount++;
|
|
1238
1353
|
{
|
|
1239
1354
|
let reqUrl = "?";
|
|
@@ -1266,6 +1381,7 @@ function createStaticPageExports({
|
|
|
1266
1381
|
});
|
|
1267
1382
|
}
|
|
1268
1383
|
const cfg = await configPromise;
|
|
1384
|
+
console.log("[WWW] render/pages:createStaticPageExports:default_ -> rendering via PagesPage kind=", kind, "locale=", locale);
|
|
1269
1385
|
return /* @__PURE__ */ jsx9(PagesPage, {
|
|
1270
1386
|
doc,
|
|
1271
1387
|
locale,
|
|
@@ -1283,11 +1399,14 @@ init_PageShowcase();
|
|
|
1283
1399
|
import { RichText as RichText2 } from "@payloadcms/richtext-lexical/react";
|
|
1284
1400
|
import { jsx as jsx10, jsxs as jsxs5, Fragment as Fragment6 } from "react/jsx-runtime";
|
|
1285
1401
|
async function PostsPage({ doc, locale, importMap: _importMap }) {
|
|
1286
|
-
if (!doc)
|
|
1402
|
+
if (!doc) {
|
|
1403
|
+
console.log("[WWW] render/pages:PostsPage no doc");
|
|
1287
1404
|
return /* @__PURE__ */ jsx10(Fragment6, {});
|
|
1405
|
+
}
|
|
1288
1406
|
const title = readText(doc.title, locale);
|
|
1289
1407
|
const excerpt = readText(doc.excerpt, locale);
|
|
1290
1408
|
const content = doc.content;
|
|
1409
|
+
console.log("[WWW] render/pages:PostsPage titleLen=", title.length, "excerptLen=", excerpt.length, "hasContent=", Boolean(content), "locale=", locale);
|
|
1291
1410
|
return /* @__PURE__ */ jsxs5("article", {
|
|
1292
1411
|
className: "posts-page prose prose-neutral dark:prose-invert mx-auto max-w-3xl py-10",
|
|
1293
1412
|
children: [
|
|
@@ -1340,11 +1459,14 @@ function readText(value, preferredLocale) {
|
|
|
1340
1459
|
import"server-only";
|
|
1341
1460
|
import { jsx as jsx11, jsxs as jsxs6, Fragment as Fragment7 } from "react/jsx-runtime";
|
|
1342
1461
|
function HeaderPage({ data, locale: _locale }) {
|
|
1343
|
-
if (!data)
|
|
1462
|
+
if (!data) {
|
|
1463
|
+
console.log("[WWW] render/pages:HeaderPage no data");
|
|
1344
1464
|
return /* @__PURE__ */ jsx11(Fragment7, {});
|
|
1465
|
+
}
|
|
1345
1466
|
const nav = data.nav ?? [];
|
|
1346
1467
|
const items = nav.filter((b) => b.blockType === "navItem");
|
|
1347
1468
|
const columns = nav.filter((b) => b.blockType === "navColumn");
|
|
1469
|
+
console.log("[WWW] render/pages:HeaderPage items=", items.length, "columns=", columns.length, "locale=", _locale);
|
|
1348
1470
|
const renderLink = (link, fallbackHref = "#") => {
|
|
1349
1471
|
if (!link)
|
|
1350
1472
|
return /* @__PURE__ */ jsx11("a", {
|
|
@@ -1398,11 +1520,14 @@ function HeaderPage({ data, locale: _locale }) {
|
|
|
1398
1520
|
import"server-only";
|
|
1399
1521
|
import { jsx as jsx12, jsxs as jsxs7, Fragment as Fragment8 } from "react/jsx-runtime";
|
|
1400
1522
|
function FooterPage({ data, locale: _locale }) {
|
|
1401
|
-
if (!data)
|
|
1523
|
+
if (!data) {
|
|
1524
|
+
console.log("[WWW] render/pages:FooterPage no data");
|
|
1402
1525
|
return /* @__PURE__ */ jsx12(Fragment8, {});
|
|
1526
|
+
}
|
|
1403
1527
|
const nav = data.nav ?? [];
|
|
1404
1528
|
const items = nav.filter((b) => b.blockType === "navItem");
|
|
1405
1529
|
const columns = nav.filter((b) => b.blockType === "navColumn");
|
|
1530
|
+
console.log("[WWW] render/pages:FooterPage items=", items.length, "columns=", columns.length, "locale=", _locale);
|
|
1406
1531
|
const renderLink = (link, fallbackHref = "#") => {
|
|
1407
1532
|
if (!link)
|
|
1408
1533
|
return /* @__PURE__ */ jsx12("a", {
|