@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.
- package/dist/access.js +13 -3
- package/dist/blocks.js +21 -7
- package/dist/collections.js +72 -19
- package/dist/components.js +1 -0
- package/dist/config.js +108 -26
- package/dist/core-access.js +13 -3
- package/dist/core-blocks.js +21 -7
- package/dist/core-fields.js +21 -7
- package/dist/core-utils.js +20 -6
- package/dist/data-collections.js +72 -19
- package/dist/data-test.js +108 -26
- package/dist/fields.js +21 -7
- package/dist/globals.js +18 -1
- package/dist/hooks.js +47 -15
- package/dist/index.js +1 -0
- package/dist/metadata.js +68 -22
- package/dist/pages.js +133 -39
- package/dist/render-components.js +13 -3
- package/dist/render-metadata.js +68 -22
- package/dist/render-pages.js +223 -59
- package/dist/render-utils.js +62 -16
- package/dist/server.js +245 -69
- package/dist/test.js +108 -26
- package/dist/utils.js +20 -6
- package/dist/with-www-config.js +108 -26
- package/package.json +1 -1
package/dist/server.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__ */ jsx6("nav", {
|
|
151
153
|
"aria-label": "Language",
|
|
152
154
|
className: "locale-switcher",
|
|
@@ -185,11 +187,21 @@ function LocaleSwitcher({
|
|
|
185
187
|
var init_LocaleSwitcher = () => {};
|
|
186
188
|
|
|
187
189
|
// src/core/access/index.ts
|
|
188
|
-
var anyone = () =>
|
|
189
|
-
|
|
190
|
+
var anyone = () => {
|
|
191
|
+
console.log("[WWW] core/access:anyone -> true");
|
|
192
|
+
return true;
|
|
193
|
+
};
|
|
194
|
+
var authenticated = ({ req: { user } }) => {
|
|
195
|
+
const result = Boolean(user);
|
|
196
|
+
console.log("[WWW] core/access:authenticated ->", result);
|
|
197
|
+
return result;
|
|
198
|
+
};
|
|
190
199
|
var authenticatedOrPublished = ({ req: { user } }) => {
|
|
191
|
-
if (user)
|
|
200
|
+
if (user) {
|
|
201
|
+
console.log("[WWW] core/access:authenticatedOrPublished -> true (authenticated)");
|
|
192
202
|
return true;
|
|
203
|
+
}
|
|
204
|
+
console.log('[WWW] core/access:authenticatedOrPublished -> { _status: { equals: "published" } }');
|
|
193
205
|
return { _status: { equals: "published" } };
|
|
194
206
|
};
|
|
195
207
|
|
|
@@ -200,6 +212,7 @@ var slugField = (options = {}) => {
|
|
|
200
212
|
const { name = "slug", nested = false, localized = true } = options;
|
|
201
213
|
const pattern = nested ? NESTED_PATTERN : FLAT_PATTERN;
|
|
202
214
|
const invalidMessage = nested ? "Slug must be lowercase, with hyphens or the `_` nesting divider (no spaces or other special characters)" : "Slug must be lowercase, with hyphens (no spaces or special characters)";
|
|
215
|
+
console.log("[WWW] core/fields:slugField options=", JSON.stringify({ name, nested, localized }));
|
|
203
216
|
return {
|
|
204
217
|
name,
|
|
205
218
|
type: "text",
|
|
@@ -214,8 +227,10 @@ var slugField = (options = {}) => {
|
|
|
214
227
|
validate: (value) => {
|
|
215
228
|
if (typeof value !== "string")
|
|
216
229
|
return "Slug must be a string";
|
|
217
|
-
if (value !== "" && !pattern.test(value))
|
|
230
|
+
if (value !== "" && !pattern.test(value)) {
|
|
231
|
+
console.warn("[WWW] core/fields:slugField invalid slug value=", JSON.stringify(value));
|
|
218
232
|
return invalidMessage;
|
|
233
|
+
}
|
|
219
234
|
return true;
|
|
220
235
|
}
|
|
221
236
|
};
|
|
@@ -223,30 +238,45 @@ var slugField = (options = {}) => {
|
|
|
223
238
|
|
|
224
239
|
// src/render/_locale.ts
|
|
225
240
|
function prefixFor(locale, defaultLocale, mode) {
|
|
241
|
+
let result;
|
|
226
242
|
if (mode === "never")
|
|
227
|
-
|
|
228
|
-
if (mode === "as-needed" && locale === defaultLocale)
|
|
229
|
-
|
|
230
|
-
|
|
243
|
+
result = "";
|
|
244
|
+
else if (mode === "as-needed" && locale === defaultLocale)
|
|
245
|
+
result = "";
|
|
246
|
+
else
|
|
247
|
+
result = `/${locale}`;
|
|
248
|
+
console.log("[WWW] render/_locale:prefixFor locale=", locale, "default=", defaultLocale, "mode=", mode, "->", JSON.stringify(result));
|
|
249
|
+
return result;
|
|
231
250
|
}
|
|
232
251
|
function resolveLocale(req) {
|
|
233
|
-
if (!req || typeof req !== "object")
|
|
252
|
+
if (!req || typeof req !== "object") {
|
|
253
|
+
console.log('[WWW] render/_locale:resolveLocale -> "" (no req)');
|
|
234
254
|
return "";
|
|
255
|
+
}
|
|
235
256
|
const r = req;
|
|
236
|
-
if (typeof r.locale === "string" && r.locale.length > 0)
|
|
257
|
+
if (typeof r.locale === "string" && r.locale.length > 0) {
|
|
258
|
+
console.log("[WWW] render/_locale:resolveLocale ->", r.locale, "(from req.locale)");
|
|
237
259
|
return r.locale;
|
|
260
|
+
}
|
|
238
261
|
const fallback = r.payload?.config?.localization?.defaultLocale;
|
|
239
|
-
if (typeof fallback === "string" && fallback.length > 0)
|
|
262
|
+
if (typeof fallback === "string" && fallback.length > 0) {
|
|
263
|
+
console.log("[WWW] render/_locale:resolveLocale ->", fallback, "(from config.localization.defaultLocale)");
|
|
240
264
|
return fallback;
|
|
265
|
+
}
|
|
266
|
+
console.log('[WWW] render/_locale:resolveLocale -> "" (no locale anywhere)');
|
|
241
267
|
return "";
|
|
242
268
|
}
|
|
243
269
|
function allLocales(req) {
|
|
244
|
-
if (!req || typeof req !== "object")
|
|
270
|
+
if (!req || typeof req !== "object") {
|
|
271
|
+
console.log("[WWW] render/_locale:allLocales -> [] (no req)");
|
|
245
272
|
return [];
|
|
273
|
+
}
|
|
246
274
|
const r = req;
|
|
247
275
|
const list = r.payload?.config?.localization?.locales;
|
|
248
|
-
if (!Array.isArray(list) || list.length === 0)
|
|
276
|
+
if (!Array.isArray(list) || list.length === 0) {
|
|
277
|
+
console.log("[WWW] render/_locale:allLocales -> [] (no locales declared)");
|
|
249
278
|
return [];
|
|
279
|
+
}
|
|
250
280
|
const out = [];
|
|
251
281
|
for (const entry of list) {
|
|
252
282
|
if (typeof entry === "string" && entry.length > 0) {
|
|
@@ -257,6 +287,7 @@ function allLocales(req) {
|
|
|
257
287
|
out.push(code);
|
|
258
288
|
}
|
|
259
289
|
}
|
|
290
|
+
console.log("[WWW] render/_locale:allLocales ->", JSON.stringify(out));
|
|
260
291
|
return out;
|
|
261
292
|
}
|
|
262
293
|
|
|
@@ -266,21 +297,28 @@ function nextCacheImport() {
|
|
|
266
297
|
return cachePromise ??= import("next/cache");
|
|
267
298
|
}
|
|
268
299
|
function shouldSkipRevalidate(context) {
|
|
269
|
-
|
|
300
|
+
const skip = Boolean(context?.disableRevalidate);
|
|
301
|
+
if (skip)
|
|
302
|
+
console.log("[WWW] render/hooks:_shared:shouldSkipRevalidate -> skip");
|
|
303
|
+
return skip;
|
|
270
304
|
}
|
|
271
305
|
async function safeRevalidatePath(payload, path) {
|
|
306
|
+
console.log("[WWW] render/hooks:_shared:safeRevalidatePath path=", path);
|
|
272
307
|
try {
|
|
273
308
|
const { revalidatePath } = await nextCacheImport();
|
|
274
309
|
revalidatePath(path);
|
|
275
310
|
} catch (error) {
|
|
311
|
+
console.error("[WWW] render/hooks:_shared:safeRevalidatePath failed path=", path, "err=", String(error));
|
|
276
312
|
payload.logger.error(`revalidatePath("${path}") failed: ${String(error)}`);
|
|
277
313
|
}
|
|
278
314
|
}
|
|
279
315
|
async function safeRevalidateTag(payload, tag, profile = "max") {
|
|
316
|
+
console.log("[WWW] render/hooks:_shared:safeRevalidateTag tag=", tag, "profile=", profile);
|
|
280
317
|
try {
|
|
281
318
|
const { revalidateTag } = await nextCacheImport();
|
|
282
319
|
revalidateTag(tag, profile);
|
|
283
320
|
} catch (error) {
|
|
321
|
+
console.error("[WWW] render/hooks:_shared:safeRevalidateTag failed tag=", tag, "err=", String(error));
|
|
284
322
|
payload.logger.error(`revalidateTag("${tag}") failed: ${String(error)}`);
|
|
285
323
|
}
|
|
286
324
|
}
|
|
@@ -296,6 +334,7 @@ function createRevalidateCollectionHook(options) {
|
|
|
296
334
|
pathMode = "url"
|
|
297
335
|
} = options;
|
|
298
336
|
const resolvedSitemapTag = sitemapTag === false ? false : sitemapTag ?? `${collectionSlug}-sitemap`;
|
|
337
|
+
console.log("[WWW] render/hooks:createRevalidateCollectionHook collectionSlug=", collectionSlug, "urlPathPrefix=", urlPathPrefix, "sitemapTag=", resolvedSitemapTag, "pathMode=", pathMode);
|
|
299
338
|
const resolveDefaults = (req) => {
|
|
300
339
|
const mode = modeOption ?? "always";
|
|
301
340
|
const defaultLocale = defaultLocaleOption ?? req?.payload?.config?.localization?.defaultLocale ?? "";
|
|
@@ -324,6 +363,7 @@ function createRevalidateCollectionHook(options) {
|
|
|
324
363
|
}
|
|
325
364
|
};
|
|
326
365
|
const fireCollectionTags = async (payload, docId, req) => {
|
|
366
|
+
console.log("[WWW] render/hooks:fireCollectionTags collectionSlug=", collectionSlug, "docId=", docId);
|
|
327
367
|
if (typeof docId === "string" || typeof docId === "number") {
|
|
328
368
|
await safeRevalidateTag(payload, `collection_${collectionSlug}_${docId}`);
|
|
329
369
|
}
|
|
@@ -337,6 +377,7 @@ function createRevalidateCollectionHook(options) {
|
|
|
337
377
|
const { payload } = req;
|
|
338
378
|
const typed = doc;
|
|
339
379
|
const prev = previousDoc;
|
|
380
|
+
console.log("[WWW] render/hooks:afterChange collectionSlug=", collectionSlug, "id=", typed.id, "slug=", typed.slug, "prevSlug=", prev?.slug);
|
|
340
381
|
const isPublished = typed._status === "published";
|
|
341
382
|
const wasPublished = prev?._status === "published";
|
|
342
383
|
const prevSlugIsString = typeof prev?.slug === "string";
|
|
@@ -360,6 +401,7 @@ function createRevalidateCollectionHook(options) {
|
|
|
360
401
|
return doc ?? null;
|
|
361
402
|
const { payload } = req;
|
|
362
403
|
const typed = doc;
|
|
404
|
+
console.log("[WWW] render/hooks:afterDelete collectionSlug=", collectionSlug, "id=", typed?.id, "slug=", typed?.slug);
|
|
363
405
|
if (pathMode !== "tag-only") {
|
|
364
406
|
await fanOutPaths(payload, req, typed?.slug, `Revalidating deleted ${collectionSlug} at path:`);
|
|
365
407
|
}
|
|
@@ -368,11 +410,14 @@ function createRevalidateCollectionHook(options) {
|
|
|
368
410
|
};
|
|
369
411
|
return { afterChange, afterDelete };
|
|
370
412
|
}
|
|
371
|
-
var createRevalidatePageHooks = (opts = {}) =>
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
413
|
+
var createRevalidatePageHooks = (opts = {}) => {
|
|
414
|
+
console.log("[WWW] render/hooks:createRevalidatePageHooks (deprecated alias) opts=", JSON.stringify(opts));
|
|
415
|
+
return createRevalidateCollectionHook({
|
|
416
|
+
collectionSlug: "pages",
|
|
417
|
+
urlPathPrefix: "",
|
|
418
|
+
...opts
|
|
419
|
+
});
|
|
420
|
+
};
|
|
376
421
|
|
|
377
422
|
// src/config/constants.ts
|
|
378
423
|
var PAGES_RENDER_PATH = "@justanarthur/payload-www/render-pages#PagesPage";
|
|
@@ -597,6 +642,13 @@ var link = (options = {}) => {
|
|
|
597
642
|
overrides = {},
|
|
598
643
|
extraFields = []
|
|
599
644
|
} = options;
|
|
645
|
+
console.log("[WWW] core/fields:link options=", JSON.stringify({
|
|
646
|
+
appearances: appearances === false ? false : appearances ?? "default-set",
|
|
647
|
+
disableLabel,
|
|
648
|
+
relationTo,
|
|
649
|
+
localized,
|
|
650
|
+
extraFieldsCount: extraFields.length
|
|
651
|
+
}));
|
|
600
652
|
const result = {
|
|
601
653
|
name: "link",
|
|
602
654
|
type: "group",
|
|
@@ -675,15 +727,18 @@ var link = (options = {}) => {
|
|
|
675
727
|
if (extraFields.length) {
|
|
676
728
|
result.fields.push(...extraFields);
|
|
677
729
|
}
|
|
730
|
+
console.log("[WWW] core/fields:link built fieldsCount=", result.fields.length);
|
|
678
731
|
return { ...result, ...overrides };
|
|
679
732
|
};
|
|
680
733
|
|
|
681
734
|
// src/render/hooks/revalidateGlobal.ts
|
|
682
735
|
function createRevalidateGlobalHook(slug) {
|
|
736
|
+
console.log("[WWW] render/hooks:createRevalidateGlobalHook slug=", slug);
|
|
683
737
|
return async ({ doc, req: { payload, context, locale } }) => {
|
|
684
738
|
if (shouldSkipRevalidate(context))
|
|
685
739
|
return doc;
|
|
686
740
|
const tags = [`global_${slug}`, `global_${slug}_${locale}`];
|
|
741
|
+
console.log("[WWW] render/hooks:revalidateGlobal slug=", slug, "locale=", locale, "tags=", JSON.stringify(tags));
|
|
687
742
|
payload.logger.info?.(`Revalidating global: ${tags.join(", ")}`);
|
|
688
743
|
for (const tag of tags) {
|
|
689
744
|
await safeRevalidateTag(payload, tag);
|
|
@@ -778,11 +833,14 @@ function createPreviewHandler(options) {
|
|
|
778
833
|
const url = new URL(req.url);
|
|
779
834
|
const path = url.searchParams.get("path") ?? "/";
|
|
780
835
|
const previewSecret = url.searchParams.get("previewSecret");
|
|
836
|
+
console.log("[WWW] render/preview:createPreviewHandler:GET path=", path, "hasSecret=", Boolean(previewSecret), "enableDraftMode=", enableDraftMode);
|
|
781
837
|
if (!previewSecret || previewSecret !== secret) {
|
|
838
|
+
console.warn("[WWW] render/preview:createPreviewHandler:GET invalid preview secret (401)");
|
|
782
839
|
return new Response("Invalid preview secret", { status: 401 });
|
|
783
840
|
}
|
|
784
841
|
if (enableDraftMode) {
|
|
785
842
|
(await draftMode()).enable();
|
|
843
|
+
console.log("[WWW] render/preview:createPreviewHandler:GET draftMode enabled");
|
|
786
844
|
}
|
|
787
845
|
redirect(path);
|
|
788
846
|
return new Response(null, { status: 204 });
|
|
@@ -802,6 +860,7 @@ async function buildHreflangAlternates({
|
|
|
802
860
|
localePrefix = "always"
|
|
803
861
|
}) {
|
|
804
862
|
const allLocaleSlugs = await queryAllLocaleSlugs(storedSlug, locale);
|
|
863
|
+
console.log("[WWW] render/metadata:buildHreflangAlternates storedSlug=", storedSlug, "locale=", locale, "allLocaleSlugs=", JSON.stringify(allLocaleSlugs));
|
|
805
864
|
const languages = {};
|
|
806
865
|
const urlFor = (l, slug) => {
|
|
807
866
|
const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
|
|
@@ -819,6 +878,7 @@ async function buildHreflangAlternates({
|
|
|
819
878
|
if (allLocaleSlugs?.[defaultLocale]) {
|
|
820
879
|
languages["x-default"] = urlFor(defaultLocale, allLocaleSlugs[defaultLocale]);
|
|
821
880
|
}
|
|
881
|
+
console.log("[WWW] render/metadata:buildHreflangAlternates ->", JSON.stringify(languages));
|
|
822
882
|
return languages;
|
|
823
883
|
}
|
|
824
884
|
|
|
@@ -828,7 +888,10 @@ import { cache } from "react";
|
|
|
828
888
|
|
|
829
889
|
// src/core/utils/getFromImportMap.ts
|
|
830
890
|
function getFromImportMap(key, importMap) {
|
|
831
|
-
|
|
891
|
+
const resolvedKey = key.includes("#") ? key : key + "#default";
|
|
892
|
+
const value = importMap[resolvedKey];
|
|
893
|
+
console.log("[WWW] core/utils:getFromImportMap key=", key, "resolved=", resolvedKey, "hit=", Boolean(value));
|
|
894
|
+
return value;
|
|
832
895
|
}
|
|
833
896
|
|
|
834
897
|
// src/render/metadata/query.ts
|
|
@@ -840,6 +903,7 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
|
|
|
840
903
|
draft = false,
|
|
841
904
|
config
|
|
842
905
|
}) {
|
|
906
|
+
console.log("[WWW] render/metadata:queryDocBySlug collection=", collectionSlug, "slug=", slug, "slugField=", slugField2, "locale=", locale, "draft=", draft);
|
|
843
907
|
const payload = await getPayload({ config });
|
|
844
908
|
const result = await payload.find({
|
|
845
909
|
collection: collectionSlug,
|
|
@@ -850,7 +914,9 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
|
|
|
850
914
|
where: { [slugField2]: { equals: slug } },
|
|
851
915
|
locale
|
|
852
916
|
});
|
|
853
|
-
|
|
917
|
+
const doc = result.docs?.[0] ?? null;
|
|
918
|
+
console.log("[WWW] render/metadata:queryDocBySlug ->", doc ? "hit" : "miss");
|
|
919
|
+
return doc;
|
|
854
920
|
});
|
|
855
921
|
var queryAllDocs = cache(async function queryAllDocs2({
|
|
856
922
|
collectionSlug,
|
|
@@ -858,6 +924,7 @@ var queryAllDocs = cache(async function queryAllDocs2({
|
|
|
858
924
|
locale,
|
|
859
925
|
config
|
|
860
926
|
}) {
|
|
927
|
+
console.log("[WWW] render/metadata:queryAllDocs collection=", collectionSlug, "locale=", locale);
|
|
861
928
|
const payload = await getPayload({ config });
|
|
862
929
|
const result = await payload.find({
|
|
863
930
|
collection: collectionSlug,
|
|
@@ -868,7 +935,9 @@ var queryAllDocs = cache(async function queryAllDocs2({
|
|
|
868
935
|
select: { [slugField2]: true },
|
|
869
936
|
locale
|
|
870
937
|
});
|
|
871
|
-
|
|
938
|
+
const docs = result.docs ?? [];
|
|
939
|
+
console.log("[WWW] render/metadata:queryAllDocs -> count=", docs.length);
|
|
940
|
+
return docs;
|
|
872
941
|
});
|
|
873
942
|
var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
874
943
|
collectionSlug,
|
|
@@ -877,6 +946,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
877
946
|
locale,
|
|
878
947
|
config
|
|
879
948
|
}) {
|
|
949
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs collection=", collectionSlug, "slug=", slug, "locale=", locale);
|
|
880
950
|
const payload = await getPayload({ config });
|
|
881
951
|
const result = await payload.find({
|
|
882
952
|
collection: collectionSlug,
|
|
@@ -889,8 +959,10 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
889
959
|
select: { [slugField2]: true }
|
|
890
960
|
});
|
|
891
961
|
const doc = result.docs?.[0];
|
|
892
|
-
if (!doc)
|
|
962
|
+
if (!doc) {
|
|
963
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> undefined (no doc)");
|
|
893
964
|
return;
|
|
965
|
+
}
|
|
894
966
|
let fieldValue = doc[slugField2];
|
|
895
967
|
if (doc.id != null) {
|
|
896
968
|
const allLocales2 = await payload.findByID({
|
|
@@ -905,6 +977,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
905
977
|
fieldValue = allLocales2[slugField2];
|
|
906
978
|
}
|
|
907
979
|
if (fieldValue && typeof fieldValue === "object") {
|
|
980
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> localized map=", JSON.stringify(fieldValue));
|
|
908
981
|
return fieldValue;
|
|
909
982
|
}
|
|
910
983
|
const resolved = await config;
|
|
@@ -912,6 +985,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
912
985
|
const out = {};
|
|
913
986
|
for (const l of rawLocales)
|
|
914
987
|
out[l] = String(fieldValue ?? slug);
|
|
988
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> flat-fanout locales=", rawLocales.length, "slug=", JSON.stringify(fieldValue ?? slug));
|
|
915
989
|
return out;
|
|
916
990
|
});
|
|
917
991
|
var queryGlobal = cache(async function queryGlobal2({
|
|
@@ -921,6 +995,7 @@ var queryGlobal = cache(async function queryGlobal2({
|
|
|
921
995
|
draft = false,
|
|
922
996
|
config
|
|
923
997
|
}) {
|
|
998
|
+
console.log("[WWW] render/metadata:queryGlobal global=", globalSlug, "locale=", locale, "depth=", depth, "draft=", draft);
|
|
924
999
|
const payload = await getPayload({ config });
|
|
925
1000
|
try {
|
|
926
1001
|
const global = await payload.findGlobal({
|
|
@@ -929,27 +1004,35 @@ var queryGlobal = cache(async function queryGlobal2({
|
|
|
929
1004
|
draft,
|
|
930
1005
|
locale
|
|
931
1006
|
});
|
|
1007
|
+
console.log("[WWW] render/metadata:queryGlobal -> hit");
|
|
932
1008
|
return global;
|
|
933
|
-
} catch {
|
|
1009
|
+
} catch (error) {
|
|
1010
|
+
console.warn("[WWW] render/metadata:queryGlobal failed for slug=", globalSlug, "err=", String(error));
|
|
934
1011
|
return null;
|
|
935
1012
|
}
|
|
936
1013
|
});
|
|
937
1014
|
function getRenderModuleExports(exportName, collection, importMap) {
|
|
938
1015
|
const path = collection?.custom?.path;
|
|
939
|
-
if (!path)
|
|
1016
|
+
if (!path) {
|
|
1017
|
+
console.log("[WWW] render/metadata:getRenderModuleExports no custom.path exportName=", exportName);
|
|
940
1018
|
return;
|
|
1019
|
+
}
|
|
941
1020
|
const mod = getFromImportMap(path, importMap);
|
|
942
|
-
|
|
1021
|
+
const value = mod?.[exportName];
|
|
1022
|
+
console.log("[WWW] render/metadata:getRenderModuleExports exportName=", exportName, "path=", path, "hit=", Boolean(value));
|
|
1023
|
+
return value;
|
|
943
1024
|
}
|
|
944
1025
|
|
|
945
1026
|
// src/render/sitemap/createSitemapFile.ts
|
|
946
1027
|
function createSitemapFile(options) {
|
|
947
1028
|
const { collections } = options;
|
|
948
1029
|
return async function sitemap() {
|
|
1030
|
+
console.log("[WWW] render/sitemap:createSitemapFile:sitemap collections=", JSON.stringify(options.collections), "localePrefix=", options.localePrefix ?? "always");
|
|
949
1031
|
const cfg = await options.config;
|
|
950
1032
|
const allLocales2 = Array.isArray(cfg.localization?.locales) ? cfg.localization.locales.map((l) => typeof l === "string" ? l : l.code) : [cfg.localization?.defaultLocale ?? "en"];
|
|
951
1033
|
const defaultLocale = cfg.localization?.defaultLocale ?? allLocales2[0];
|
|
952
1034
|
const activeLocales = Array.isArray(options.locales) && options.locales.length > 0 ? options.locales.filter((l) => allLocales2.includes(l)) : allLocales2;
|
|
1035
|
+
console.log("[WWW] render/sitemap:createSitemapFile:sitemap allLocales=", JSON.stringify(allLocales2), "default=", defaultLocale, "active=", JSON.stringify(activeLocales));
|
|
953
1036
|
const entries = [];
|
|
954
1037
|
const seen = new Set;
|
|
955
1038
|
for (const collectionSlug of collections) {
|
|
@@ -1005,6 +1088,7 @@ function createSitemapFile(options) {
|
|
|
1005
1088
|
}
|
|
1006
1089
|
}
|
|
1007
1090
|
}
|
|
1091
|
+
console.log("[WWW] render/sitemap:createSitemapFile:sitemap -> entries=", entries.length);
|
|
1008
1092
|
return entries;
|
|
1009
1093
|
};
|
|
1010
1094
|
}
|
|
@@ -1110,21 +1194,31 @@ function createWWWConfig(options) {
|
|
|
1110
1194
|
}
|
|
1111
1195
|
|
|
1112
1196
|
// src/core/fields/linkGroup.ts
|
|
1113
|
-
var linkGroup = (options = {}) =>
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1197
|
+
var linkGroup = (options = {}) => {
|
|
1198
|
+
console.log("[WWW] core/fields:linkGroup relationTo=", JSON.stringify(options.relationTo ?? "link-default"), "extraFields=", options.extraFields?.length ?? 0);
|
|
1199
|
+
return {
|
|
1200
|
+
name: "links",
|
|
1201
|
+
type: "array",
|
|
1202
|
+
fields: [link(options)],
|
|
1203
|
+
admin: { initCollapsed: true }
|
|
1204
|
+
};
|
|
1205
|
+
};
|
|
1119
1206
|
|
|
1120
1207
|
// src/core/utils/generateImportName.ts
|
|
1121
1208
|
function generateImportName(type, slug) {
|
|
1122
1209
|
switch (type) {
|
|
1123
|
-
case "block":
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
return
|
|
1210
|
+
case "block": {
|
|
1211
|
+
const name = `Block${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
1212
|
+
console.log("[WWW] core/utils:generateImportName type=block slug=", slug, "->", name);
|
|
1213
|
+
return name;
|
|
1214
|
+
}
|
|
1215
|
+
case "page": {
|
|
1216
|
+
const name = `Page${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
1217
|
+
console.log("[WWW] core/utils:generateImportName type=page slug=", slug, "->", name);
|
|
1218
|
+
return name;
|
|
1219
|
+
}
|
|
1127
1220
|
default:
|
|
1221
|
+
console.error("[WWW] core/utils:generateImportName unknown type:", type);
|
|
1128
1222
|
throw new Error(`Unknown type: ${type}`);
|
|
1129
1223
|
}
|
|
1130
1224
|
}
|
|
@@ -1133,13 +1227,17 @@ function generateImportName(type, slug) {
|
|
|
1133
1227
|
import { jsx } from "react/jsx-runtime";
|
|
1134
1228
|
function renderCollectionModule(collection = [], slug, importMap, props) {
|
|
1135
1229
|
const renderPath = collection?.find((c) => c.slug === slug)?.custom?.path;
|
|
1136
|
-
if (!renderPath)
|
|
1230
|
+
if (!renderPath) {
|
|
1231
|
+
console.log("[WWW] render/utils:renderCollectionModule no custom.path slug=", slug);
|
|
1137
1232
|
return null;
|
|
1233
|
+
}
|
|
1138
1234
|
const CollectionRenderModule = getFromImportMap(renderPath, importMap);
|
|
1139
1235
|
if (!CollectionRenderModule) {
|
|
1236
|
+
console.error("[WWW] render/utils:renderCollectionModule not found slug=", slug, "path=", renderPath);
|
|
1140
1237
|
if (false) {}
|
|
1141
1238
|
return null;
|
|
1142
1239
|
}
|
|
1240
|
+
console.log("[WWW] render/utils:renderCollectionModule rendering slug=", slug, "path=", renderPath);
|
|
1143
1241
|
return /* @__PURE__ */ jsx(CollectionRenderModule, {
|
|
1144
1242
|
importMap,
|
|
1145
1243
|
...props
|
|
@@ -1150,13 +1248,17 @@ function renderCollectionModule(collection = [], slug, importMap, props) {
|
|
|
1150
1248
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
1151
1249
|
function renderGlobalModule(globals = [], slug, importMap, props) {
|
|
1152
1250
|
const renderPath = globals?.find((g) => g.slug === slug)?.custom?.path;
|
|
1153
|
-
if (!renderPath)
|
|
1251
|
+
if (!renderPath) {
|
|
1252
|
+
console.log("[WWW] render/utils:renderGlobalModule no custom.path slug=", slug);
|
|
1154
1253
|
return null;
|
|
1254
|
+
}
|
|
1155
1255
|
const GlobalRenderModule = getFromImportMap(renderPath, importMap);
|
|
1156
1256
|
if (!GlobalRenderModule) {
|
|
1257
|
+
console.error("[WWW] render/utils:renderGlobalModule not found slug=", slug, "path=", renderPath);
|
|
1157
1258
|
if (false) {}
|
|
1158
1259
|
return null;
|
|
1159
1260
|
}
|
|
1261
|
+
console.log("[WWW] render/utils:renderGlobalModule rendering slug=", slug, "path=", renderPath);
|
|
1160
1262
|
return /* @__PURE__ */ jsx2(GlobalRenderModule, {
|
|
1161
1263
|
importMap,
|
|
1162
1264
|
...props
|
|
@@ -1165,12 +1267,15 @@ function renderGlobalModule(globals = [], slug, importMap, props) {
|
|
|
1165
1267
|
|
|
1166
1268
|
// src/render/utils/getCachedGlobal.ts
|
|
1167
1269
|
import { unstable_cache } from "next/cache";
|
|
1168
|
-
var getCachedGlobal = (config, slug, depth = 0) =>
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1270
|
+
var getCachedGlobal = (config, slug, depth = 0) => {
|
|
1271
|
+
console.log("[WWW] render/utils:getCachedGlobal slug=", slug, "depth=", depth);
|
|
1272
|
+
return unstable_cache(async () => queryGlobal({
|
|
1273
|
+
globalSlug: slug,
|
|
1274
|
+
locale: "__ALL__",
|
|
1275
|
+
depth,
|
|
1276
|
+
config
|
|
1277
|
+
}), [slug], { tags: [`global_${slug}`] });
|
|
1278
|
+
};
|
|
1174
1279
|
|
|
1175
1280
|
// src/render/metadata/jsonld.ts
|
|
1176
1281
|
function getImageUrl(doc, siteUrl) {
|
|
@@ -1183,6 +1288,11 @@ function getImageUrl(doc, siteUrl) {
|
|
|
1183
1288
|
return img.url.startsWith("http") ? img.url : `${siteUrl}${img.url}`;
|
|
1184
1289
|
return null;
|
|
1185
1290
|
}
|
|
1291
|
+
function getImageUrlWithLog(doc, siteUrl) {
|
|
1292
|
+
const result = getImageUrl(doc, siteUrl);
|
|
1293
|
+
console.log("[WWW] render/metadata:jsonld:getImageUrl ->", result);
|
|
1294
|
+
return result;
|
|
1295
|
+
}
|
|
1186
1296
|
function resolveLocalizedField(value, locale) {
|
|
1187
1297
|
if (value == null)
|
|
1188
1298
|
return "";
|
|
@@ -1204,6 +1314,13 @@ function resolveLocalizedField(value, locale) {
|
|
|
1204
1314
|
}
|
|
1205
1315
|
return Object.values(obj).filter((v) => typeof v === "string" && v.length > 0).join(" / ");
|
|
1206
1316
|
}
|
|
1317
|
+
function resolveLocalizedFieldWithLog(value, locale) {
|
|
1318
|
+
const result = resolveLocalizedField(value, locale);
|
|
1319
|
+
if (value && typeof value === "object") {
|
|
1320
|
+
console.log("[WWW] render/metadata:jsonld:resolveLocalizedField locale=", locale, "->", JSON.stringify(result));
|
|
1321
|
+
}
|
|
1322
|
+
return result;
|
|
1323
|
+
}
|
|
1207
1324
|
function buildArticleLd({
|
|
1208
1325
|
doc,
|
|
1209
1326
|
url,
|
|
@@ -1214,12 +1331,13 @@ function buildArticleLd({
|
|
|
1214
1331
|
publisherLogo
|
|
1215
1332
|
}) {
|
|
1216
1333
|
const name = publisherName ?? new URL(siteUrl).hostname;
|
|
1334
|
+
console.log("[WWW] render/metadata:buildArticleLd url=", url, "locale=", locale, "type=", type, "publisherName=", name);
|
|
1217
1335
|
const ld = {
|
|
1218
1336
|
"@context": "https://schema.org",
|
|
1219
1337
|
"@type": type,
|
|
1220
1338
|
"@id": `${url}#article`,
|
|
1221
|
-
headline:
|
|
1222
|
-
description:
|
|
1339
|
+
headline: resolveLocalizedFieldWithLog(doc.title, locale),
|
|
1340
|
+
description: resolveLocalizedFieldWithLog(doc.meta?.description ?? doc.description ?? doc.excerpt, locale),
|
|
1223
1341
|
inLanguage: locale,
|
|
1224
1342
|
url,
|
|
1225
1343
|
dateModified: doc.updatedAt ? new Date(doc.updatedAt).toISOString() : undefined
|
|
@@ -1227,7 +1345,7 @@ function buildArticleLd({
|
|
|
1227
1345
|
const datePublished = doc.publishedAt ?? doc.createdAt;
|
|
1228
1346
|
if (datePublished)
|
|
1229
1347
|
ld.datePublished = new Date(datePublished).toISOString();
|
|
1230
|
-
const imgUrl =
|
|
1348
|
+
const imgUrl = getImageUrlWithLog(doc, siteUrl);
|
|
1231
1349
|
if (imgUrl)
|
|
1232
1350
|
ld.image = imgUrl;
|
|
1233
1351
|
ld.author = { "@type": "Organization", name, url: siteUrl };
|
|
@@ -1243,6 +1361,7 @@ function buildBreadcrumbsLd({
|
|
|
1243
1361
|
items,
|
|
1244
1362
|
currentUrl
|
|
1245
1363
|
}) {
|
|
1364
|
+
console.log("[WWW] render/metadata:buildBreadcrumbsLd items=", items.length, "currentUrl=", currentUrl);
|
|
1246
1365
|
return {
|
|
1247
1366
|
"@context": "https://schema.org",
|
|
1248
1367
|
"@type": "BreadcrumbList",
|
|
@@ -1260,6 +1379,7 @@ function buildOrganizationLd({
|
|
|
1260
1379
|
logo,
|
|
1261
1380
|
sameAs
|
|
1262
1381
|
}) {
|
|
1382
|
+
console.log("[WWW] render/metadata:buildOrganizationLd siteUrl=", siteUrl, "name=", name, "logo?", Boolean(logo), "sameAs?", Boolean(sameAs));
|
|
1263
1383
|
const org = {
|
|
1264
1384
|
"@context": "https://schema.org",
|
|
1265
1385
|
"@type": "Organization",
|
|
@@ -1275,23 +1395,29 @@ function buildOrganizationLd({
|
|
|
1275
1395
|
// src/render/metadata/slug.ts
|
|
1276
1396
|
var SLUG_NESTED_DIVIDER = "_";
|
|
1277
1397
|
function segmentsToStoredSlug(segments, nested) {
|
|
1278
|
-
if (!Array.isArray(segments))
|
|
1398
|
+
if (!Array.isArray(segments)) {
|
|
1399
|
+
console.log("[WWW] render/metadata:segmentsToStoredSlug string passthrough:", JSON.stringify(segments));
|
|
1279
1400
|
return segments;
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1401
|
+
}
|
|
1402
|
+
const result = nested ? segments.join(SLUG_NESTED_DIVIDER) : segments[0] ?? "";
|
|
1403
|
+
console.log("[WWW] render/metadata:segmentsToStoredSlug nested=", nested, "segments=", JSON.stringify(segments), "->", result);
|
|
1404
|
+
return result;
|
|
1283
1405
|
}
|
|
1284
1406
|
function segmentsToUrlPath(segments, nested) {
|
|
1407
|
+
let result;
|
|
1285
1408
|
if (!Array.isArray(segments))
|
|
1286
|
-
|
|
1287
|
-
if (nested)
|
|
1288
|
-
|
|
1289
|
-
|
|
1409
|
+
result = "/" + segments;
|
|
1410
|
+
else if (nested)
|
|
1411
|
+
result = "/" + segments.join("/");
|
|
1412
|
+
else
|
|
1413
|
+
result = "/" + (segments[0] ?? "");
|
|
1414
|
+
console.log("[WWW] render/metadata:segmentsToUrlPath nested=", nested, "segments=", JSON.stringify(segments), "->", result);
|
|
1415
|
+
return result;
|
|
1290
1416
|
}
|
|
1291
1417
|
function storedSlugToSegments(storedSlug, nested) {
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
return
|
|
1418
|
+
const result = nested ? storedSlug.split(SLUG_NESTED_DIVIDER) : storedSlug;
|
|
1419
|
+
console.log("[WWW] render/metadata:storedSlugToSegments nested=", nested, "storedSlug=", storedSlug, "->", JSON.stringify(result));
|
|
1420
|
+
return result;
|
|
1295
1421
|
}
|
|
1296
1422
|
function buildCanonicalUrl({
|
|
1297
1423
|
siteUrl,
|
|
@@ -1301,7 +1427,9 @@ function buildCanonicalUrl({
|
|
|
1301
1427
|
}) {
|
|
1302
1428
|
const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
|
|
1303
1429
|
const prefixSegment = trimmedPrefix ? `/${trimmedPrefix}` : "";
|
|
1304
|
-
|
|
1430
|
+
const result = `${siteUrl}/${locale}${prefixSegment}${urlPath}`;
|
|
1431
|
+
console.log("[WWW] render/metadata:buildCanonicalUrl siteUrl=", siteUrl, "locale=", locale, "urlPrefix=", urlPrefix, "urlPath=", urlPath, "->", result);
|
|
1432
|
+
return result;
|
|
1305
1433
|
}
|
|
1306
1434
|
function getUrlPath(segments, nested, homeSlug) {
|
|
1307
1435
|
const urlPath = segmentsToUrlPath(segments, nested);
|
|
@@ -1326,8 +1454,11 @@ var RenderBlocks = ({
|
|
|
1326
1454
|
locale,
|
|
1327
1455
|
searchParams
|
|
1328
1456
|
}) => {
|
|
1329
|
-
if (!blocks || !Array.isArray(blocks) || blocks.length === 0)
|
|
1457
|
+
if (!blocks || !Array.isArray(blocks) || blocks.length === 0) {
|
|
1458
|
+
console.log("[WWW] render/blocks:RenderBlocks no blocks (locale=", locale, ")");
|
|
1330
1459
|
return null;
|
|
1460
|
+
}
|
|
1461
|
+
console.log("[WWW] render/blocks:RenderBlocks rendering count=", blocks.length, "locale=", locale);
|
|
1331
1462
|
const rendered = [];
|
|
1332
1463
|
for (let i = 0;i < blocks.length; i++) {
|
|
1333
1464
|
const block = blocks[i];
|
|
@@ -1335,9 +1466,10 @@ var RenderBlocks = ({
|
|
|
1335
1466
|
const importMapPath = config.admin?.dependencies?.[blockType]?.path ?? generateImportName("block", blockType);
|
|
1336
1467
|
const Block = getFromImportMap(importMapPath, importMap);
|
|
1337
1468
|
if (!Block) {
|
|
1338
|
-
console.warn(`
|
|
1469
|
+
console.warn(`[WWW] render/blocks:RenderBlocks no block for type=${blockType} importMapPath=${importMapPath} (locale=${locale})`);
|
|
1339
1470
|
continue;
|
|
1340
1471
|
}
|
|
1472
|
+
console.log("[WWW] render/blocks:RenderBlocks [", i, "] blockType=", blockType, "importMapPath=", importMapPath);
|
|
1341
1473
|
rendered.push(/* @__PURE__ */ jsx3(Block, {
|
|
1342
1474
|
index: i,
|
|
1343
1475
|
...blockProps,
|
|
@@ -1650,9 +1782,12 @@ import { RichText } from "@payloadcms/richtext-lexical/react";
|
|
|
1650
1782
|
// src/render/pages/PagesPage.tsx
|
|
1651
1783
|
import { jsx as jsx4, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
1652
1784
|
async function PagesPage({ doc, ...props }) {
|
|
1653
|
-
if (!doc)
|
|
1785
|
+
if (!doc) {
|
|
1786
|
+
console.log("[WWW] render/pages:PagesPage no doc");
|
|
1654
1787
|
return /* @__PURE__ */ jsx4(Fragment2, {});
|
|
1788
|
+
}
|
|
1655
1789
|
const blocks = doc.blocks ?? [];
|
|
1790
|
+
console.log("[WWW] render/pages:PagesPage blocks=", blocks.length, "locale=", props.locale);
|
|
1656
1791
|
return /* @__PURE__ */ jsx4(Fragment2, {
|
|
1657
1792
|
children: /* @__PURE__ */ jsx4(RenderBlocks, {
|
|
1658
1793
|
blocks,
|
|
@@ -1690,11 +1825,15 @@ function createCollectionPageExports({
|
|
|
1690
1825
|
const localePrefixMode = typeof routing.localePrefix === "string" ? routing.localePrefix : routing.localePrefix?.mode ?? "always";
|
|
1691
1826
|
const buildLocalePath = (locale, storedSlug) => {
|
|
1692
1827
|
const urlPath = getUrlPath(storedSlugToSegments(storedSlug, nested), nested, HOME_SLUG);
|
|
1828
|
+
let result;
|
|
1693
1829
|
if (localePrefixMode === "never")
|
|
1694
|
-
|
|
1695
|
-
if (localePrefixMode === "as-needed" && locale === defaultLocale)
|
|
1696
|
-
|
|
1697
|
-
|
|
1830
|
+
result = urlPath;
|
|
1831
|
+
else if (localePrefixMode === "as-needed" && locale === defaultLocale)
|
|
1832
|
+
result = urlPath;
|
|
1833
|
+
else
|
|
1834
|
+
result = `/${locale}${urlPath}`;
|
|
1835
|
+
console.log("[WWW] render/pages:createCollectionPageExports:buildLocalePath locale=", locale, "storedSlug=", storedSlug, "->", result);
|
|
1836
|
+
return result;
|
|
1698
1837
|
};
|
|
1699
1838
|
async function fetchDoc(locale, storedSlug, draft = false) {
|
|
1700
1839
|
return queryDocBySlug({
|
|
@@ -1725,13 +1864,16 @@ function createCollectionPageExports({
|
|
|
1725
1864
|
for (const [key, url] of Object.entries(languages)) {
|
|
1726
1865
|
alternates[key] = url;
|
|
1727
1866
|
}
|
|
1867
|
+
console.log("[WWW] render/pages:createCollectionPageExports:resolveHreflangAlternates canonical=", canonical, "alts=", JSON.stringify(alternates));
|
|
1728
1868
|
return { alternates, canonical };
|
|
1729
1869
|
}
|
|
1730
1870
|
const default_ = async (props) => {
|
|
1731
1871
|
const { slug: rawSlugSegments, locale: incomingLocale } = await props.params ?? {};
|
|
1732
1872
|
const slugSegments = Array.isArray(rawSlugSegments) ? rawSlugSegments : [];
|
|
1733
1873
|
const locale = typeof incomingLocale === "string" ? incomingLocale : defaultLocale;
|
|
1874
|
+
console.log("[WWW] render/pages:createCollectionPageExports:default_ collectionSlug=", slug, "locale=", locale, "segments=", JSON.stringify(slugSegments), "showcase=", showcaseEnabled);
|
|
1734
1875
|
if (!locales.includes(locale)) {
|
|
1876
|
+
console.error(`[WWW] render/pages:createCollectionPageExports:default_ notFound invalid-locale collection=${slug} locale=${locale} segments=${JSON.stringify(slugSegments)}`);
|
|
1735
1877
|
const { notFound } = await import("next/navigation");
|
|
1736
1878
|
notFound();
|
|
1737
1879
|
}
|
|
@@ -1739,15 +1881,18 @@ function createCollectionPageExports({
|
|
|
1739
1881
|
setRequestLocale(locale);
|
|
1740
1882
|
const { draftMode } = await import("next/headers");
|
|
1741
1883
|
const { isEnabled: draft } = await draftMode();
|
|
1884
|
+
console.log("[WWW] render/pages:createCollectionPageExports:default_ draftMode=", draft);
|
|
1742
1885
|
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
1743
1886
|
const doc = await fetchDoc(locale, storedSlug, draft);
|
|
1744
1887
|
if (!doc) {
|
|
1888
|
+
console.error(`[WWW] render/pages:createCollectionPageExports:default_ notFound no-doc collection=${slug} locale=${locale} storedSlug="${storedSlug}" segments=${JSON.stringify(slugSegments)} draft=${draft}`);
|
|
1745
1889
|
const { notFound } = await import("next/navigation");
|
|
1746
1890
|
notFound();
|
|
1747
1891
|
}
|
|
1748
1892
|
const cfg = await configPromise;
|
|
1749
1893
|
const collectionCustomPath = cfg.collections.find((c) => c.slug === slug)?.custom?.path;
|
|
1750
1894
|
const effectivePath = renderPath ?? collectionCustomPath ?? defaultRenderPath;
|
|
1895
|
+
console.log("[WWW] render/pages:createCollectionPageExports:default_ effectivePath=", effectivePath);
|
|
1751
1896
|
const render = effectivePath === PAGES_RENDER_PATH ? /* @__PURE__ */ jsx7(PagesPage, {
|
|
1752
1897
|
doc,
|
|
1753
1898
|
importMap,
|
|
@@ -1809,15 +1954,22 @@ function createCollectionPageExports({
|
|
|
1809
1954
|
const { slug: rawSlugSegments, locale: incomingLocale } = await props.params ?? {};
|
|
1810
1955
|
const slugSegments = Array.isArray(rawSlugSegments) ? rawSlugSegments : [];
|
|
1811
1956
|
const locale = typeof incomingLocale === "string" ? incomingLocale : defaultLocale;
|
|
1812
|
-
|
|
1957
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateMetadata collectionSlug=", slug, "locale=", locale, "segments=", JSON.stringify(slugSegments));
|
|
1958
|
+
if (!locales.includes(locale)) {
|
|
1959
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateMetadata invalid locale -> not found meta");
|
|
1813
1960
|
return { title: "Not found", robots: { index: false, follow: false } };
|
|
1961
|
+
}
|
|
1814
1962
|
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
1815
1963
|
const doc = await fetchDoc(locale, storedSlug);
|
|
1816
|
-
if (!doc)
|
|
1964
|
+
if (!doc) {
|
|
1965
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateMetadata no doc -> not found meta");
|
|
1817
1966
|
return { title: "Not found", robots: { index: false, follow: false } };
|
|
1967
|
+
}
|
|
1818
1968
|
const collection = cfg.collections.find((c) => c.slug === slug);
|
|
1819
|
-
if (!collection)
|
|
1969
|
+
if (!collection) {
|
|
1970
|
+
console.warn("[WWW] render/pages:createCollectionPageExports:generateMetadata collection not in config slug=", slug);
|
|
1820
1971
|
return {};
|
|
1972
|
+
}
|
|
1821
1973
|
const { canonical, alternates } = await resolveHreflangAlternates(locale, storedSlug);
|
|
1822
1974
|
const meta = await generateMeta({
|
|
1823
1975
|
doc,
|
|
@@ -1839,6 +1991,7 @@ function createCollectionPageExports({
|
|
|
1839
1991
|
const urlPath = buildLocalePath(locale, storedSlug);
|
|
1840
1992
|
const canonical = `${siteUrl}${urlPath}`;
|
|
1841
1993
|
const entries = Array.isArray(jsonLdOption) ? jsonLdOption : metadataType === "article" ? [{ type: "article" }] : [{ type: "website" }];
|
|
1994
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateJsonLd collection=", slug, "locale=", locale, "entries=", entries.map((e) => e.type).join(","));
|
|
1842
1995
|
const outputs = [];
|
|
1843
1996
|
for (const entry of entries) {
|
|
1844
1997
|
const id = entry.id ?? `jsonld-${entry.type}-${outputs.length}`;
|
|
@@ -1899,6 +2052,7 @@ function createCollectionPageExports({
|
|
|
1899
2052
|
return outputs;
|
|
1900
2053
|
}
|
|
1901
2054
|
async function generateStaticParams() {
|
|
2055
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateStaticParams collection=", slug, "locales=", JSON.stringify(locales));
|
|
1902
2056
|
const params = [];
|
|
1903
2057
|
for (const locale of locales) {
|
|
1904
2058
|
const docs = await queryAllDocs({ collectionSlug: slug, slugField: "slug", locale, config: configPromise });
|
|
@@ -1910,9 +2064,11 @@ function createCollectionPageExports({
|
|
|
1910
2064
|
params.push({ slug: Array.isArray(segments) ? segments : [segments], locale });
|
|
1911
2065
|
}
|
|
1912
2066
|
}
|
|
2067
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateStaticParams -> count=", params.length);
|
|
1913
2068
|
return params;
|
|
1914
2069
|
}
|
|
1915
2070
|
async function generateSitemap() {
|
|
2071
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateSitemap collection=", slug, "locales=", JSON.stringify(locales));
|
|
1916
2072
|
const docs = await queryAllDocs({
|
|
1917
2073
|
collectionSlug: slug,
|
|
1918
2074
|
slugField: "slug",
|
|
@@ -1932,6 +2088,7 @@ function createCollectionPageExports({
|
|
|
1932
2088
|
urls.push({ url: `${siteUrl}${urlPath}`, lastModified: lastmod, changeFrequency: changefreq, priority });
|
|
1933
2089
|
}
|
|
1934
2090
|
}
|
|
2091
|
+
console.log("[WWW] render/pages:createCollectionPageExports:generateSitemap -> urls=", urls.length);
|
|
1935
2092
|
return urls;
|
|
1936
2093
|
}
|
|
1937
2094
|
return {
|
|
@@ -1989,9 +2146,27 @@ function createStaticPageExports({
|
|
|
1989
2146
|
importMap: importMapArg
|
|
1990
2147
|
}) {
|
|
1991
2148
|
const importMap = importMapArg ?? {};
|
|
2149
|
+
let dbgRenderCount = 0;
|
|
1992
2150
|
const default_ = async () => {
|
|
1993
2151
|
const { getLocale } = await import("next-intl/server");
|
|
1994
2152
|
const locale = await getLocale();
|
|
2153
|
+
console.log("[WWW] render/pages:createStaticPageExports:default_ kind=", kind, "locale=", locale);
|
|
2154
|
+
dbgRenderCount++;
|
|
2155
|
+
{
|
|
2156
|
+
let reqUrl = "?";
|
|
2157
|
+
try {
|
|
2158
|
+
const { headers } = await import("next/headers");
|
|
2159
|
+
const h = await headers();
|
|
2160
|
+
reqUrl = h.get("x-invoke-path") || h.get("x-matched-path") || h.get("x-next-url") || h.get("next-url") || h.get("referer") || "?";
|
|
2161
|
+
} catch {}
|
|
2162
|
+
console.error(`[WWW-DBG static-render #${dbgRenderCount}] kind=${kind} locale=${locale} url=${reqUrl}`);
|
|
2163
|
+
if (dbgRenderCount <= 5) {
|
|
2164
|
+
console.error(`[WWW-DBG static-render #${dbgRenderCount}] stack:
|
|
2165
|
+
` + (new Error("static-render").stack?.split(`
|
|
2166
|
+
`).slice(2, 12).join(`
|
|
2167
|
+
`) ?? ""));
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
1995
2170
|
const doc = await queryDocBySlug({
|
|
1996
2171
|
collectionSlug: STATIC_PAGES_SLUG,
|
|
1997
2172
|
slug: kind,
|
|
@@ -2008,6 +2183,7 @@ function createStaticPageExports({
|
|
|
2008
2183
|
});
|
|
2009
2184
|
}
|
|
2010
2185
|
const cfg = await configPromise;
|
|
2186
|
+
console.log("[WWW] render/pages:createStaticPageExports:default_ -> rendering via PagesPage kind=", kind, "locale=", locale);
|
|
2011
2187
|
return /* @__PURE__ */ jsx8(PagesPage, {
|
|
2012
2188
|
doc,
|
|
2013
2189
|
locale,
|