@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/test.js
CHANGED
|
@@ -22,11 +22,21 @@ import path from "node:path";
|
|
|
22
22
|
import { fileURLToPath } from "node:url";
|
|
23
23
|
|
|
24
24
|
// src/core/access/index.ts
|
|
25
|
-
var anyone = () =>
|
|
26
|
-
|
|
25
|
+
var anyone = () => {
|
|
26
|
+
console.log("[WWW] core/access:anyone -> true");
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
var authenticated = ({ req: { user } }) => {
|
|
30
|
+
const result = Boolean(user);
|
|
31
|
+
console.log("[WWW] core/access:authenticated ->", result);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
27
34
|
var authenticatedOrPublished = ({ req: { user } }) => {
|
|
28
|
-
if (user)
|
|
35
|
+
if (user) {
|
|
36
|
+
console.log("[WWW] core/access:authenticatedOrPublished -> true (authenticated)");
|
|
29
37
|
return true;
|
|
38
|
+
}
|
|
39
|
+
console.log('[WWW] core/access:authenticatedOrPublished -> { _status: { equals: "published" } }');
|
|
30
40
|
return { _status: { equals: "published" } };
|
|
31
41
|
};
|
|
32
42
|
|
|
@@ -37,6 +47,7 @@ var slugField = (options = {}) => {
|
|
|
37
47
|
const { name = "slug", nested = false, localized = true } = options;
|
|
38
48
|
const pattern = nested ? NESTED_PATTERN : FLAT_PATTERN;
|
|
39
49
|
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)";
|
|
50
|
+
console.log("[WWW] core/fields:slugField options=", JSON.stringify({ name, nested, localized }));
|
|
40
51
|
return {
|
|
41
52
|
name,
|
|
42
53
|
type: "text",
|
|
@@ -51,8 +62,10 @@ var slugField = (options = {}) => {
|
|
|
51
62
|
validate: (value) => {
|
|
52
63
|
if (typeof value !== "string")
|
|
53
64
|
return "Slug must be a string";
|
|
54
|
-
if (value !== "" && !pattern.test(value))
|
|
65
|
+
if (value !== "" && !pattern.test(value)) {
|
|
66
|
+
console.warn("[WWW] core/fields:slugField invalid slug value=", JSON.stringify(value));
|
|
55
67
|
return invalidMessage;
|
|
68
|
+
}
|
|
56
69
|
return true;
|
|
57
70
|
}
|
|
58
71
|
};
|
|
@@ -60,30 +73,45 @@ var slugField = (options = {}) => {
|
|
|
60
73
|
|
|
61
74
|
// src/render/_locale.ts
|
|
62
75
|
function prefixFor(locale, defaultLocale, mode) {
|
|
76
|
+
let result;
|
|
63
77
|
if (mode === "never")
|
|
64
|
-
|
|
65
|
-
if (mode === "as-needed" && locale === defaultLocale)
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
result = "";
|
|
79
|
+
else if (mode === "as-needed" && locale === defaultLocale)
|
|
80
|
+
result = "";
|
|
81
|
+
else
|
|
82
|
+
result = `/${locale}`;
|
|
83
|
+
console.log("[WWW] render/_locale:prefixFor locale=", locale, "default=", defaultLocale, "mode=", mode, "->", JSON.stringify(result));
|
|
84
|
+
return result;
|
|
68
85
|
}
|
|
69
86
|
function resolveLocale(req) {
|
|
70
|
-
if (!req || typeof req !== "object")
|
|
87
|
+
if (!req || typeof req !== "object") {
|
|
88
|
+
console.log('[WWW] render/_locale:resolveLocale -> "" (no req)');
|
|
71
89
|
return "";
|
|
90
|
+
}
|
|
72
91
|
const r = req;
|
|
73
|
-
if (typeof r.locale === "string" && r.locale.length > 0)
|
|
92
|
+
if (typeof r.locale === "string" && r.locale.length > 0) {
|
|
93
|
+
console.log("[WWW] render/_locale:resolveLocale ->", r.locale, "(from req.locale)");
|
|
74
94
|
return r.locale;
|
|
95
|
+
}
|
|
75
96
|
const fallback = r.payload?.config?.localization?.defaultLocale;
|
|
76
|
-
if (typeof fallback === "string" && fallback.length > 0)
|
|
97
|
+
if (typeof fallback === "string" && fallback.length > 0) {
|
|
98
|
+
console.log("[WWW] render/_locale:resolveLocale ->", fallback, "(from config.localization.defaultLocale)");
|
|
77
99
|
return fallback;
|
|
100
|
+
}
|
|
101
|
+
console.log('[WWW] render/_locale:resolveLocale -> "" (no locale anywhere)');
|
|
78
102
|
return "";
|
|
79
103
|
}
|
|
80
104
|
function allLocales(req) {
|
|
81
|
-
if (!req || typeof req !== "object")
|
|
105
|
+
if (!req || typeof req !== "object") {
|
|
106
|
+
console.log("[WWW] render/_locale:allLocales -> [] (no req)");
|
|
82
107
|
return [];
|
|
108
|
+
}
|
|
83
109
|
const r = req;
|
|
84
110
|
const list = r.payload?.config?.localization?.locales;
|
|
85
|
-
if (!Array.isArray(list) || list.length === 0)
|
|
111
|
+
if (!Array.isArray(list) || list.length === 0) {
|
|
112
|
+
console.log("[WWW] render/_locale:allLocales -> [] (no locales declared)");
|
|
86
113
|
return [];
|
|
114
|
+
}
|
|
87
115
|
const out = [];
|
|
88
116
|
for (const entry of list) {
|
|
89
117
|
if (typeof entry === "string" && entry.length > 0) {
|
|
@@ -94,6 +122,7 @@ function allLocales(req) {
|
|
|
94
122
|
out.push(code);
|
|
95
123
|
}
|
|
96
124
|
}
|
|
125
|
+
console.log("[WWW] render/_locale:allLocales ->", JSON.stringify(out));
|
|
97
126
|
return out;
|
|
98
127
|
}
|
|
99
128
|
|
|
@@ -103,21 +132,28 @@ function nextCacheImport() {
|
|
|
103
132
|
return cachePromise ??= import("next/cache");
|
|
104
133
|
}
|
|
105
134
|
function shouldSkipRevalidate(context) {
|
|
106
|
-
|
|
135
|
+
const skip = Boolean(context?.disableRevalidate);
|
|
136
|
+
if (skip)
|
|
137
|
+
console.log("[WWW] render/hooks:_shared:shouldSkipRevalidate -> skip");
|
|
138
|
+
return skip;
|
|
107
139
|
}
|
|
108
140
|
async function safeRevalidatePath(payload, path) {
|
|
141
|
+
console.log("[WWW] render/hooks:_shared:safeRevalidatePath path=", path);
|
|
109
142
|
try {
|
|
110
143
|
const { revalidatePath } = await nextCacheImport();
|
|
111
144
|
revalidatePath(path);
|
|
112
145
|
} catch (error) {
|
|
146
|
+
console.error("[WWW] render/hooks:_shared:safeRevalidatePath failed path=", path, "err=", String(error));
|
|
113
147
|
payload.logger.error(`revalidatePath("${path}") failed: ${String(error)}`);
|
|
114
148
|
}
|
|
115
149
|
}
|
|
116
150
|
async function safeRevalidateTag(payload, tag, profile = "max") {
|
|
151
|
+
console.log("[WWW] render/hooks:_shared:safeRevalidateTag tag=", tag, "profile=", profile);
|
|
117
152
|
try {
|
|
118
153
|
const { revalidateTag } = await nextCacheImport();
|
|
119
154
|
revalidateTag(tag, profile);
|
|
120
155
|
} catch (error) {
|
|
156
|
+
console.error("[WWW] render/hooks:_shared:safeRevalidateTag failed tag=", tag, "err=", String(error));
|
|
121
157
|
payload.logger.error(`revalidateTag("${tag}") failed: ${String(error)}`);
|
|
122
158
|
}
|
|
123
159
|
}
|
|
@@ -133,6 +169,7 @@ function createRevalidateCollectionHook(options) {
|
|
|
133
169
|
pathMode = "url"
|
|
134
170
|
} = options;
|
|
135
171
|
const resolvedSitemapTag = sitemapTag === false ? false : sitemapTag ?? `${collectionSlug}-sitemap`;
|
|
172
|
+
console.log("[WWW] render/hooks:createRevalidateCollectionHook collectionSlug=", collectionSlug, "urlPathPrefix=", urlPathPrefix, "sitemapTag=", resolvedSitemapTag, "pathMode=", pathMode);
|
|
136
173
|
const resolveDefaults = (req) => {
|
|
137
174
|
const mode = modeOption ?? "always";
|
|
138
175
|
const defaultLocale = defaultLocaleOption ?? req?.payload?.config?.localization?.defaultLocale ?? "";
|
|
@@ -161,6 +198,7 @@ function createRevalidateCollectionHook(options) {
|
|
|
161
198
|
}
|
|
162
199
|
};
|
|
163
200
|
const fireCollectionTags = async (payload, docId, req) => {
|
|
201
|
+
console.log("[WWW] render/hooks:fireCollectionTags collectionSlug=", collectionSlug, "docId=", docId);
|
|
164
202
|
if (typeof docId === "string" || typeof docId === "number") {
|
|
165
203
|
await safeRevalidateTag(payload, `collection_${collectionSlug}_${docId}`);
|
|
166
204
|
}
|
|
@@ -174,6 +212,7 @@ function createRevalidateCollectionHook(options) {
|
|
|
174
212
|
const { payload } = req;
|
|
175
213
|
const typed = doc;
|
|
176
214
|
const prev = previousDoc;
|
|
215
|
+
console.log("[WWW] render/hooks:afterChange collectionSlug=", collectionSlug, "id=", typed.id, "slug=", typed.slug, "prevSlug=", prev?.slug);
|
|
177
216
|
const isPublished = typed._status === "published";
|
|
178
217
|
const wasPublished = prev?._status === "published";
|
|
179
218
|
const prevSlugIsString = typeof prev?.slug === "string";
|
|
@@ -197,6 +236,7 @@ function createRevalidateCollectionHook(options) {
|
|
|
197
236
|
return doc ?? null;
|
|
198
237
|
const { payload } = req;
|
|
199
238
|
const typed = doc;
|
|
239
|
+
console.log("[WWW] render/hooks:afterDelete collectionSlug=", collectionSlug, "id=", typed?.id, "slug=", typed?.slug);
|
|
200
240
|
if (pathMode !== "tag-only") {
|
|
201
241
|
await fanOutPaths(payload, req, typed?.slug, `Revalidating deleted ${collectionSlug} at path:`);
|
|
202
242
|
}
|
|
@@ -205,11 +245,14 @@ function createRevalidateCollectionHook(options) {
|
|
|
205
245
|
};
|
|
206
246
|
return { afterChange, afterDelete };
|
|
207
247
|
}
|
|
208
|
-
var createRevalidatePageHooks = (opts = {}) =>
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
248
|
+
var createRevalidatePageHooks = (opts = {}) => {
|
|
249
|
+
console.log("[WWW] render/hooks:createRevalidatePageHooks (deprecated alias) opts=", JSON.stringify(opts));
|
|
250
|
+
return createRevalidateCollectionHook({
|
|
251
|
+
collectionSlug: "pages",
|
|
252
|
+
urlPathPrefix: "",
|
|
253
|
+
...opts
|
|
254
|
+
});
|
|
255
|
+
};
|
|
213
256
|
|
|
214
257
|
// src/config/constants.ts
|
|
215
258
|
var PAGES_RENDER_PATH = "@justanarthur/payload-www/render-pages#PagesPage";
|
|
@@ -434,6 +477,13 @@ var link = (options = {}) => {
|
|
|
434
477
|
overrides = {},
|
|
435
478
|
extraFields = []
|
|
436
479
|
} = options;
|
|
480
|
+
console.log("[WWW] core/fields:link options=", JSON.stringify({
|
|
481
|
+
appearances: appearances === false ? false : appearances ?? "default-set",
|
|
482
|
+
disableLabel,
|
|
483
|
+
relationTo,
|
|
484
|
+
localized,
|
|
485
|
+
extraFieldsCount: extraFields.length
|
|
486
|
+
}));
|
|
437
487
|
const result = {
|
|
438
488
|
name: "link",
|
|
439
489
|
type: "group",
|
|
@@ -512,15 +562,18 @@ var link = (options = {}) => {
|
|
|
512
562
|
if (extraFields.length) {
|
|
513
563
|
result.fields.push(...extraFields);
|
|
514
564
|
}
|
|
565
|
+
console.log("[WWW] core/fields:link built fieldsCount=", result.fields.length);
|
|
515
566
|
return { ...result, ...overrides };
|
|
516
567
|
};
|
|
517
568
|
|
|
518
569
|
// src/render/hooks/revalidateGlobal.ts
|
|
519
570
|
function createRevalidateGlobalHook(slug) {
|
|
571
|
+
console.log("[WWW] render/hooks:createRevalidateGlobalHook slug=", slug);
|
|
520
572
|
return async ({ doc, req: { payload, context, locale } }) => {
|
|
521
573
|
if (shouldSkipRevalidate(context))
|
|
522
574
|
return doc;
|
|
523
575
|
const tags = [`global_${slug}`, `global_${slug}_${locale}`];
|
|
576
|
+
console.log("[WWW] render/hooks:revalidateGlobal slug=", slug, "locale=", locale, "tags=", JSON.stringify(tags));
|
|
524
577
|
payload.logger.info?.(`Revalidating global: ${tags.join(", ")}`);
|
|
525
578
|
for (const tag of tags) {
|
|
526
579
|
await safeRevalidateTag(payload, tag);
|
|
@@ -615,11 +668,14 @@ function createPreviewHandler(options) {
|
|
|
615
668
|
const url = new URL(req.url);
|
|
616
669
|
const path = url.searchParams.get("path") ?? "/";
|
|
617
670
|
const previewSecret = url.searchParams.get("previewSecret");
|
|
671
|
+
console.log("[WWW] render/preview:createPreviewHandler:GET path=", path, "hasSecret=", Boolean(previewSecret), "enableDraftMode=", enableDraftMode);
|
|
618
672
|
if (!previewSecret || previewSecret !== secret) {
|
|
673
|
+
console.warn("[WWW] render/preview:createPreviewHandler:GET invalid preview secret (401)");
|
|
619
674
|
return new Response("Invalid preview secret", { status: 401 });
|
|
620
675
|
}
|
|
621
676
|
if (enableDraftMode) {
|
|
622
677
|
(await draftMode()).enable();
|
|
678
|
+
console.log("[WWW] render/preview:createPreviewHandler:GET draftMode enabled");
|
|
623
679
|
}
|
|
624
680
|
redirect(path);
|
|
625
681
|
return new Response(null, { status: 204 });
|
|
@@ -639,6 +695,7 @@ async function buildHreflangAlternates({
|
|
|
639
695
|
localePrefix = "always"
|
|
640
696
|
}) {
|
|
641
697
|
const allLocaleSlugs = await queryAllLocaleSlugs(storedSlug, locale);
|
|
698
|
+
console.log("[WWW] render/metadata:buildHreflangAlternates storedSlug=", storedSlug, "locale=", locale, "allLocaleSlugs=", JSON.stringify(allLocaleSlugs));
|
|
642
699
|
const languages = {};
|
|
643
700
|
const urlFor = (l, slug) => {
|
|
644
701
|
const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
|
|
@@ -656,6 +713,7 @@ async function buildHreflangAlternates({
|
|
|
656
713
|
if (allLocaleSlugs?.[defaultLocale]) {
|
|
657
714
|
languages["x-default"] = urlFor(defaultLocale, allLocaleSlugs[defaultLocale]);
|
|
658
715
|
}
|
|
716
|
+
console.log("[WWW] render/metadata:buildHreflangAlternates ->", JSON.stringify(languages));
|
|
659
717
|
return languages;
|
|
660
718
|
}
|
|
661
719
|
|
|
@@ -665,7 +723,10 @@ import { cache } from "react";
|
|
|
665
723
|
|
|
666
724
|
// src/core/utils/getFromImportMap.ts
|
|
667
725
|
function getFromImportMap(key, importMap) {
|
|
668
|
-
|
|
726
|
+
const resolvedKey = key.includes("#") ? key : key + "#default";
|
|
727
|
+
const value = importMap[resolvedKey];
|
|
728
|
+
console.log("[WWW] core/utils:getFromImportMap key=", key, "resolved=", resolvedKey, "hit=", Boolean(value));
|
|
729
|
+
return value;
|
|
669
730
|
}
|
|
670
731
|
|
|
671
732
|
// src/render/metadata/query.ts
|
|
@@ -677,6 +738,7 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
|
|
|
677
738
|
draft = false,
|
|
678
739
|
config
|
|
679
740
|
}) {
|
|
741
|
+
console.log("[WWW] render/metadata:queryDocBySlug collection=", collectionSlug, "slug=", slug, "slugField=", slugField2, "locale=", locale, "draft=", draft);
|
|
680
742
|
const payload = await getPayload({ config });
|
|
681
743
|
const result = await payload.find({
|
|
682
744
|
collection: collectionSlug,
|
|
@@ -687,7 +749,9 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
|
|
|
687
749
|
where: { [slugField2]: { equals: slug } },
|
|
688
750
|
locale
|
|
689
751
|
});
|
|
690
|
-
|
|
752
|
+
const doc = result.docs?.[0] ?? null;
|
|
753
|
+
console.log("[WWW] render/metadata:queryDocBySlug ->", doc ? "hit" : "miss");
|
|
754
|
+
return doc;
|
|
691
755
|
});
|
|
692
756
|
var queryAllDocs = cache(async function queryAllDocs2({
|
|
693
757
|
collectionSlug,
|
|
@@ -695,6 +759,7 @@ var queryAllDocs = cache(async function queryAllDocs2({
|
|
|
695
759
|
locale,
|
|
696
760
|
config
|
|
697
761
|
}) {
|
|
762
|
+
console.log("[WWW] render/metadata:queryAllDocs collection=", collectionSlug, "locale=", locale);
|
|
698
763
|
const payload = await getPayload({ config });
|
|
699
764
|
const result = await payload.find({
|
|
700
765
|
collection: collectionSlug,
|
|
@@ -705,7 +770,9 @@ var queryAllDocs = cache(async function queryAllDocs2({
|
|
|
705
770
|
select: { [slugField2]: true },
|
|
706
771
|
locale
|
|
707
772
|
});
|
|
708
|
-
|
|
773
|
+
const docs = result.docs ?? [];
|
|
774
|
+
console.log("[WWW] render/metadata:queryAllDocs -> count=", docs.length);
|
|
775
|
+
return docs;
|
|
709
776
|
});
|
|
710
777
|
var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
711
778
|
collectionSlug,
|
|
@@ -714,6 +781,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
714
781
|
locale,
|
|
715
782
|
config
|
|
716
783
|
}) {
|
|
784
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs collection=", collectionSlug, "slug=", slug, "locale=", locale);
|
|
717
785
|
const payload = await getPayload({ config });
|
|
718
786
|
const result = await payload.find({
|
|
719
787
|
collection: collectionSlug,
|
|
@@ -726,8 +794,10 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
726
794
|
select: { [slugField2]: true }
|
|
727
795
|
});
|
|
728
796
|
const doc = result.docs?.[0];
|
|
729
|
-
if (!doc)
|
|
797
|
+
if (!doc) {
|
|
798
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> undefined (no doc)");
|
|
730
799
|
return;
|
|
800
|
+
}
|
|
731
801
|
let fieldValue = doc[slugField2];
|
|
732
802
|
if (doc.id != null) {
|
|
733
803
|
const allLocales2 = await payload.findByID({
|
|
@@ -742,6 +812,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
742
812
|
fieldValue = allLocales2[slugField2];
|
|
743
813
|
}
|
|
744
814
|
if (fieldValue && typeof fieldValue === "object") {
|
|
815
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> localized map=", JSON.stringify(fieldValue));
|
|
745
816
|
return fieldValue;
|
|
746
817
|
}
|
|
747
818
|
const resolved = await config;
|
|
@@ -749,6 +820,7 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
749
820
|
const out = {};
|
|
750
821
|
for (const l of rawLocales)
|
|
751
822
|
out[l] = String(fieldValue ?? slug);
|
|
823
|
+
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> flat-fanout locales=", rawLocales.length, "slug=", JSON.stringify(fieldValue ?? slug));
|
|
752
824
|
return out;
|
|
753
825
|
});
|
|
754
826
|
var queryGlobal = cache(async function queryGlobal2({
|
|
@@ -758,6 +830,7 @@ var queryGlobal = cache(async function queryGlobal2({
|
|
|
758
830
|
draft = false,
|
|
759
831
|
config
|
|
760
832
|
}) {
|
|
833
|
+
console.log("[WWW] render/metadata:queryGlobal global=", globalSlug, "locale=", locale, "depth=", depth, "draft=", draft);
|
|
761
834
|
const payload = await getPayload({ config });
|
|
762
835
|
try {
|
|
763
836
|
const global = await payload.findGlobal({
|
|
@@ -766,27 +839,35 @@ var queryGlobal = cache(async function queryGlobal2({
|
|
|
766
839
|
draft,
|
|
767
840
|
locale
|
|
768
841
|
});
|
|
842
|
+
console.log("[WWW] render/metadata:queryGlobal -> hit");
|
|
769
843
|
return global;
|
|
770
|
-
} catch {
|
|
844
|
+
} catch (error) {
|
|
845
|
+
console.warn("[WWW] render/metadata:queryGlobal failed for slug=", globalSlug, "err=", String(error));
|
|
771
846
|
return null;
|
|
772
847
|
}
|
|
773
848
|
});
|
|
774
849
|
function getRenderModuleExports(exportName, collection, importMap) {
|
|
775
850
|
const path = collection?.custom?.path;
|
|
776
|
-
if (!path)
|
|
851
|
+
if (!path) {
|
|
852
|
+
console.log("[WWW] render/metadata:getRenderModuleExports no custom.path exportName=", exportName);
|
|
777
853
|
return;
|
|
854
|
+
}
|
|
778
855
|
const mod = getFromImportMap(path, importMap);
|
|
779
|
-
|
|
856
|
+
const value = mod?.[exportName];
|
|
857
|
+
console.log("[WWW] render/metadata:getRenderModuleExports exportName=", exportName, "path=", path, "hit=", Boolean(value));
|
|
858
|
+
return value;
|
|
780
859
|
}
|
|
781
860
|
|
|
782
861
|
// src/render/sitemap/createSitemapFile.ts
|
|
783
862
|
function createSitemapFile(options) {
|
|
784
863
|
const { collections } = options;
|
|
785
864
|
return async function sitemap() {
|
|
865
|
+
console.log("[WWW] render/sitemap:createSitemapFile:sitemap collections=", JSON.stringify(options.collections), "localePrefix=", options.localePrefix ?? "always");
|
|
786
866
|
const cfg = await options.config;
|
|
787
867
|
const allLocales2 = Array.isArray(cfg.localization?.locales) ? cfg.localization.locales.map((l) => typeof l === "string" ? l : l.code) : [cfg.localization?.defaultLocale ?? "en"];
|
|
788
868
|
const defaultLocale = cfg.localization?.defaultLocale ?? allLocales2[0];
|
|
789
869
|
const activeLocales = Array.isArray(options.locales) && options.locales.length > 0 ? options.locales.filter((l) => allLocales2.includes(l)) : allLocales2;
|
|
870
|
+
console.log("[WWW] render/sitemap:createSitemapFile:sitemap allLocales=", JSON.stringify(allLocales2), "default=", defaultLocale, "active=", JSON.stringify(activeLocales));
|
|
790
871
|
const entries = [];
|
|
791
872
|
const seen = new Set;
|
|
792
873
|
for (const collectionSlug of collections) {
|
|
@@ -842,6 +923,7 @@ function createSitemapFile(options) {
|
|
|
842
923
|
}
|
|
843
924
|
}
|
|
844
925
|
}
|
|
926
|
+
console.log("[WWW] render/sitemap:createSitemapFile:sitemap -> entries=", entries.length);
|
|
845
927
|
return entries;
|
|
846
928
|
};
|
|
847
929
|
}
|
package/dist/utils.js
CHANGED
|
@@ -17,17 +17,27 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
17
17
|
|
|
18
18
|
// src/core/utils/getFromImportMap.ts
|
|
19
19
|
function getFromImportMap(key, importMap) {
|
|
20
|
-
|
|
20
|
+
const resolvedKey = key.includes("#") ? key : key + "#default";
|
|
21
|
+
const value = importMap[resolvedKey];
|
|
22
|
+
console.log("[WWW] core/utils:getFromImportMap key=", key, "resolved=", resolvedKey, "hit=", Boolean(value));
|
|
23
|
+
return value;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
// src/core/utils/generateImportName.ts
|
|
24
27
|
function generateImportName(type, slug) {
|
|
25
28
|
switch (type) {
|
|
26
|
-
case "block":
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
29
|
+
case "block": {
|
|
30
|
+
const name = `Block${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
31
|
+
console.log("[WWW] core/utils:generateImportName type=block slug=", slug, "->", name);
|
|
32
|
+
return name;
|
|
33
|
+
}
|
|
34
|
+
case "page": {
|
|
35
|
+
const name = `Page${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
36
|
+
console.log("[WWW] core/utils:generateImportName type=page slug=", slug, "->", name);
|
|
37
|
+
return name;
|
|
38
|
+
}
|
|
30
39
|
default:
|
|
40
|
+
console.error("[WWW] core/utils:generateImportName unknown type:", type);
|
|
31
41
|
throw new Error(`Unknown type: ${type}`);
|
|
32
42
|
}
|
|
33
43
|
}
|
|
@@ -36,13 +46,17 @@ function generateImportName(type, slug) {
|
|
|
36
46
|
import { jsx } from "react/jsx-runtime";
|
|
37
47
|
function renderCollectionModule(collection = [], slug, importMap, props) {
|
|
38
48
|
const renderPath = collection?.find((c) => c.slug === slug)?.custom?.path;
|
|
39
|
-
if (!renderPath)
|
|
49
|
+
if (!renderPath) {
|
|
50
|
+
console.log("[WWW] render/utils:renderCollectionModule no custom.path slug=", slug);
|
|
40
51
|
return null;
|
|
52
|
+
}
|
|
41
53
|
const CollectionRenderModule = getFromImportMap(renderPath, importMap);
|
|
42
54
|
if (!CollectionRenderModule) {
|
|
55
|
+
console.error("[WWW] render/utils:renderCollectionModule not found slug=", slug, "path=", renderPath);
|
|
43
56
|
if (false) {}
|
|
44
57
|
return null;
|
|
45
58
|
}
|
|
59
|
+
console.log("[WWW] render/utils:renderCollectionModule rendering slug=", slug, "path=", renderPath);
|
|
46
60
|
return /* @__PURE__ */ jsx(CollectionRenderModule, {
|
|
47
61
|
importMap,
|
|
48
62
|
...props
|