@justanarthur/payload-www 0.3.4 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +317 -307
- package/dist/access.d.ts +2 -2
- package/dist/access.js +6 -30
- package/dist/blocks.d.ts +0 -10
- package/dist/blocks.js +8 -33
- package/dist/collections.d.ts +33 -225
- package/dist/collections.js +186 -661
- package/dist/config.d.ts +19 -105
- package/dist/config.js +263 -868
- package/dist/fields.d.ts +4 -46
- package/dist/fields.js +183 -73
- package/dist/imagehash.js +0 -15
- package/dist/import-map-provider.d.ts +0 -16
- package/dist/import-map-provider.js +0 -15
- package/dist/metadata.d.ts +24 -89
- package/dist/metadata.js +123 -258
- package/dist/pages.d.ts +37 -319
- package/dist/pages.js +355 -973
- package/dist/render-pages.d.ts +69 -564
- package/dist/render-pages.js +476 -1502
- package/dist/sitemap.d.ts +10 -0
- package/dist/sitemap.js +324 -0
- package/dist/translator.js +0 -15
- package/dist/utils.d.ts +4 -12
- package/dist/utils.js +10 -56
- package/package.json +75 -178
- package/dist/components.d.ts +0 -6
- package/dist/components.js +0 -39
- package/dist/core-access.d.ts +0 -11
- package/dist/core-access.js +0 -44
- package/dist/core-blocks.d.ts +0 -24
- package/dist/core-blocks.js +0 -89
- package/dist/core-fields.d.ts +0 -73
- package/dist/core-fields.js +0 -181
- package/dist/core-utils.d.ts +0 -16
- package/dist/core-utils.js +0 -73
- package/dist/data-collections.d.ts +0 -229
- package/dist/data-collections.js +0 -697
- package/dist/data-seed.d.ts +0 -76
- package/dist/data-seed.js +0 -212
- package/dist/data-test.d.ts +0 -30
- package/dist/data-test.js +0 -1134
- package/dist/globals.d.ts +0 -69
- package/dist/globals.js +0 -259
- package/dist/hooks.d.ts +0 -108
- package/dist/hooks.js +0 -228
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -39
- package/dist/render-components.d.ts +0 -42
- package/dist/render-components.js +0 -154
- package/dist/render-metadata.d.ts +0 -122
- package/dist/render-metadata.js +0 -393
- package/dist/render-utils.d.ts +0 -166
- package/dist/render-utils.js +0 -401
- package/dist/seed.d.ts +0 -76
- package/dist/seed.js +0 -212
- package/dist/server.d.ts +0 -980
- package/dist/server.js +0 -2265
- package/dist/test.d.ts +0 -30
- package/dist/test.js +0 -1134
- package/dist/with-www-config.d.ts +0 -108
- package/dist/with-www-config.js +0 -1030
package/dist/render-pages.js
CHANGED
|
@@ -1,592 +1,138 @@
|
|
|
1
1
|
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
-
|
|
18
|
-
// src/render/components/PageShowcase.tsx
|
|
19
|
-
var exports_PageShowcase = {};
|
|
20
|
-
__export(exports_PageShowcase, {
|
|
21
|
-
PageShowcase: () => PageShowcase
|
|
22
|
-
});
|
|
23
|
-
import * as React from "react";
|
|
24
|
-
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
25
|
-
function PageShowcase({
|
|
26
|
-
children,
|
|
27
|
-
metadata,
|
|
28
|
-
jsonLd,
|
|
29
|
-
localeSwitcher,
|
|
30
|
-
metadataHeading = "Page metadata",
|
|
31
|
-
jsonLdHeading = "JSON-LD"
|
|
32
|
-
}) {
|
|
33
|
-
console.log("[WWW] render/components:PageShowcase jsonLdEntries=", jsonLd.length, "hasOg=", Boolean(metadata.openGraph), "hasTwitter=", Boolean(metadata.twitter), "canonical=", metadata.alternates?.canonical);
|
|
34
|
-
const og = metadata.openGraph;
|
|
35
|
-
const twitter = metadata.twitter;
|
|
36
|
-
const rows = [
|
|
37
|
-
["Title", resolveTitle(metadata.title)],
|
|
38
|
-
["Description", metadata.description],
|
|
39
|
-
["Canonical", metadata.alternates?.canonical],
|
|
40
|
-
[
|
|
41
|
-
"Languages",
|
|
42
|
-
metadata.alternates?.languages ? Object.entries(metadata.alternates.languages).map(([locale, url]) => `${locale}: ${url}`).join(`
|
|
43
|
-
`) : undefined
|
|
44
|
-
],
|
|
45
|
-
["Open Graph title", og?.title],
|
|
46
|
-
["Open Graph description", og?.description],
|
|
47
|
-
["Open Graph type", og?.type],
|
|
48
|
-
["Open Graph url", og?.url],
|
|
49
|
-
["Open Graph site name", og?.siteName],
|
|
50
|
-
["Twitter card", twitter?.card],
|
|
51
|
-
["Twitter title", twitter?.title],
|
|
52
|
-
["Twitter description", twitter?.description],
|
|
53
|
-
["Twitter site", twitter?.site],
|
|
54
|
-
["Twitter creator", twitter?.creator]
|
|
55
|
-
];
|
|
56
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
57
|
-
className: "page-showcase grid gap-8 lg:grid-cols-[1fr_320px]",
|
|
58
|
-
children: [
|
|
59
|
-
/* @__PURE__ */ jsx4("main", {
|
|
60
|
-
className: "page-showcase__main",
|
|
61
|
-
children
|
|
62
|
-
}),
|
|
63
|
-
/* @__PURE__ */ jsxs("aside", {
|
|
64
|
-
className: "page-showcase__sidebar flex flex-col gap-6 text-sm",
|
|
65
|
-
children: [
|
|
66
|
-
/* @__PURE__ */ jsxs("section", {
|
|
67
|
-
className: "page-showcase__locale",
|
|
68
|
-
children: [
|
|
69
|
-
/* @__PURE__ */ jsx4("h2", {
|
|
70
|
-
className: "m-0 mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",
|
|
71
|
-
children: "Language"
|
|
72
|
-
}),
|
|
73
|
-
localeSwitcher
|
|
74
|
-
]
|
|
75
|
-
}),
|
|
76
|
-
/* @__PURE__ */ jsxs("section", {
|
|
77
|
-
className: "page-showcase__metadata",
|
|
78
|
-
children: [
|
|
79
|
-
/* @__PURE__ */ jsx4("h2", {
|
|
80
|
-
className: "m-0 mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",
|
|
81
|
-
children: metadataHeading
|
|
82
|
-
}),
|
|
83
|
-
/* @__PURE__ */ jsx4("dl", {
|
|
84
|
-
className: "m-0 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1.5",
|
|
85
|
-
children: rows.filter(([, value]) => value !== undefined && value !== "").map(([label, value]) => /* @__PURE__ */ jsxs(React.Fragment, {
|
|
86
|
-
children: [
|
|
87
|
-
/* @__PURE__ */ jsx4("dt", {
|
|
88
|
-
className: "font-medium text-muted-foreground",
|
|
89
|
-
children: label
|
|
90
|
-
}),
|
|
91
|
-
/* @__PURE__ */ jsx4("dd", {
|
|
92
|
-
className: "m-0 whitespace-pre-wrap break-words font-mono text-xs",
|
|
93
|
-
children: value
|
|
94
|
-
})
|
|
95
|
-
]
|
|
96
|
-
}, label))
|
|
97
|
-
})
|
|
98
|
-
]
|
|
99
|
-
}),
|
|
100
|
-
jsonLd.length > 0 ? /* @__PURE__ */ jsxs("section", {
|
|
101
|
-
className: "page-showcase__jsonld",
|
|
102
|
-
children: [
|
|
103
|
-
/* @__PURE__ */ jsx4("h2", {
|
|
104
|
-
className: "m-0 mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",
|
|
105
|
-
children: jsonLdHeading
|
|
106
|
-
}),
|
|
107
|
-
jsonLd.map(({ id, schema }) => /* @__PURE__ */ jsxs("details", {
|
|
108
|
-
className: "mb-2 rounded border border-border bg-muted/30 p-2",
|
|
109
|
-
children: [
|
|
110
|
-
/* @__PURE__ */ jsx4("summary", {
|
|
111
|
-
className: "cursor-pointer font-mono text-xs",
|
|
112
|
-
children: id
|
|
113
|
-
}),
|
|
114
|
-
/* @__PURE__ */ jsx4("pre", {
|
|
115
|
-
className: "mt-2 overflow-x-auto whitespace-pre-wrap break-words font-mono text-[10px] leading-snug",
|
|
116
|
-
children: JSON.stringify(schema, null, 2)
|
|
117
|
-
})
|
|
118
|
-
]
|
|
119
|
-
}, id))
|
|
120
|
-
]
|
|
121
|
-
}) : null
|
|
122
|
-
]
|
|
123
|
-
})
|
|
124
|
-
]
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
function resolveTitle(title) {
|
|
128
|
-
if (!title)
|
|
129
|
-
return;
|
|
130
|
-
if (typeof title === "string")
|
|
131
|
-
return title;
|
|
132
|
-
if (title === null)
|
|
133
|
-
return;
|
|
134
|
-
const t = title;
|
|
135
|
-
return t.absolute ?? t.template ?? t.default;
|
|
136
|
-
}
|
|
137
|
-
var init_PageShowcase = () => {};
|
|
138
2
|
|
|
139
|
-
// src/render/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
3
|
+
// src/render/pages/FooterPage.tsx
|
|
4
|
+
import"server-only";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
function FooterPage({ data }) {
|
|
7
|
+
const nav = data.nav ?? [];
|
|
8
|
+
const items = nav.filter((b) => b.blockType === "navItem");
|
|
9
|
+
const columns = nav.filter((b) => b.blockType === "navColumn");
|
|
10
|
+
const renderLink = (link, fallbackHref = "#") => {
|
|
11
|
+
if (!link)
|
|
12
|
+
return /* @__PURE__ */ jsx("a", {
|
|
13
|
+
href: fallbackHref,
|
|
14
|
+
children: link?.label ?? ""
|
|
15
|
+
});
|
|
16
|
+
if (link.type === "custom" && typeof link.url === "string") {
|
|
17
|
+
return /* @__PURE__ */ jsx("a", {
|
|
18
|
+
href: link.url,
|
|
19
|
+
children: link.label
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (link.type === "reference" && link.reference) {
|
|
23
|
+
const ref = link.reference;
|
|
24
|
+
if (typeof ref === "object" && ref.slug) {
|
|
25
|
+
return /* @__PURE__ */ jsx("a", {
|
|
26
|
+
href: `/${ref.slug}`,
|
|
27
|
+
children: link.label
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return /* @__PURE__ */ jsx("a", {
|
|
32
|
+
href: fallbackHref,
|
|
33
|
+
children: link.label ?? ""
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
return /* @__PURE__ */ jsx("footer", {
|
|
37
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
157
38
|
children: [
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
"
|
|
170
|
-
|
|
39
|
+
items.map((item, i) => /* @__PURE__ */ jsx("span", {
|
|
40
|
+
style: { marginRight: 16 },
|
|
41
|
+
children: renderLink(item.link)
|
|
42
|
+
}, `item-${i}`)),
|
|
43
|
+
columns.map((col, i) => /* @__PURE__ */ jsxs("div", {
|
|
44
|
+
style: { display: "inline-block", marginRight: 24, verticalAlign: "top" },
|
|
45
|
+
children: [
|
|
46
|
+
col.title ? /* @__PURE__ */ jsx("strong", {
|
|
47
|
+
children: col.title
|
|
48
|
+
}) : null,
|
|
49
|
+
/* @__PURE__ */ jsx("div", {
|
|
50
|
+
children: (col.links ?? []).map((entry, j) => /* @__PURE__ */ jsx("div", {
|
|
51
|
+
children: renderLink(entry.link)
|
|
52
|
+
}, `col-${i}-link-${j}`))
|
|
171
53
|
})
|
|
172
|
-
|
|
173
|
-
})
|
|
174
|
-
hreflangAlternates["x-default"] ? /* @__PURE__ */ jsx5("li", {
|
|
175
|
-
children: /* @__PURE__ */ jsx5("a", {
|
|
176
|
-
href: hreflangAlternates["x-default"],
|
|
177
|
-
hrefLang: "x-default",
|
|
178
|
-
className: "locale-switcher__link",
|
|
179
|
-
"data-locale": "x-default",
|
|
180
|
-
children: labels?.["x-default"] ?? "Default"
|
|
181
|
-
})
|
|
182
|
-
}, "x-default") : null
|
|
54
|
+
]
|
|
55
|
+
}, `col-${i}`))
|
|
183
56
|
]
|
|
184
57
|
})
|
|
185
58
|
});
|
|
186
59
|
}
|
|
187
|
-
var init_LocaleSwitcher = () => {};
|
|
188
60
|
|
|
189
|
-
// src/render/pages/
|
|
61
|
+
// src/render/pages/HeaderPage.tsx
|
|
190
62
|
import"server-only";
|
|
191
|
-
import {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
console.log("[WWW] core/utils:getFromImportMap key=", key, "resolved=", resolvedKey, "hit=", Boolean(value));
|
|
208
|
-
return value;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// src/render/utils/renderCollectionModule.tsx
|
|
212
|
-
import { jsx } from "react/jsx-runtime";
|
|
213
|
-
function renderCollectionModule(collection = [], slug, importMap, props) {
|
|
214
|
-
const renderPath = collection?.find((c) => c.slug === slug)?.custom?.path;
|
|
215
|
-
if (!renderPath) {
|
|
216
|
-
console.log("[WWW] render/utils:renderCollectionModule no custom.path slug=", slug);
|
|
217
|
-
return null;
|
|
218
|
-
}
|
|
219
|
-
const CollectionRenderModule = getFromImportMap(renderPath, importMap);
|
|
220
|
-
if (!CollectionRenderModule) {
|
|
221
|
-
console.error("[WWW] render/utils:renderCollectionModule not found slug=", slug, "path=", renderPath);
|
|
222
|
-
if (false) {}
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
console.log("[WWW] render/utils:renderCollectionModule rendering slug=", slug, "path=", renderPath);
|
|
226
|
-
return /* @__PURE__ */ jsx(CollectionRenderModule, {
|
|
227
|
-
importMap,
|
|
228
|
-
...props
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// src/render/metadata/hreflang.ts
|
|
233
|
-
async function buildHreflangAlternates({
|
|
234
|
-
siteUrl,
|
|
235
|
-
locale,
|
|
236
|
-
urlPrefix,
|
|
237
|
-
storedSlug,
|
|
238
|
-
queryAllLocaleSlugs,
|
|
239
|
-
nested,
|
|
240
|
-
homeSlug,
|
|
241
|
-
defaultLocale,
|
|
242
|
-
locales,
|
|
243
|
-
localePrefix = "always"
|
|
244
|
-
}) {
|
|
245
|
-
const allLocaleSlugs = await queryAllLocaleSlugs(storedSlug, locale);
|
|
246
|
-
console.log("[WWW] render/metadata:buildHreflangAlternates storedSlug=", storedSlug, "locale=", locale, "allLocaleSlugs=", JSON.stringify(allLocaleSlugs));
|
|
247
|
-
const languages = {};
|
|
248
|
-
const urlFor = (l, slug) => {
|
|
249
|
-
const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
|
|
250
|
-
const prefixSegment = trimmedPrefix ? `/${trimmedPrefix}` : "";
|
|
251
|
-
const urlPath = slug === homeSlug ? "/" : nested ? "/" + slug.replaceAll("_", "/") : "/" + slug;
|
|
252
|
-
const localeSegment = localePrefix === "never" ? "" : localePrefix === "as-needed" && l === defaultLocale ? "" : `/${l}`;
|
|
253
|
-
return `${siteUrl}${localeSegment}${prefixSegment}${urlPath}`;
|
|
254
|
-
};
|
|
255
|
-
for (const l of locales) {
|
|
256
|
-
const slugForLocale = allLocaleSlugs?.[l];
|
|
257
|
-
if (!slugForLocale)
|
|
258
|
-
continue;
|
|
259
|
-
languages[l] = urlFor(l, slugForLocale);
|
|
260
|
-
}
|
|
261
|
-
if (allLocaleSlugs?.[defaultLocale]) {
|
|
262
|
-
languages["x-default"] = urlFor(defaultLocale, allLocaleSlugs[defaultLocale]);
|
|
263
|
-
}
|
|
264
|
-
console.log("[WWW] render/metadata:buildHreflangAlternates ->", JSON.stringify(languages));
|
|
265
|
-
return languages;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// src/render/metadata/jsonld.ts
|
|
269
|
-
function getImageUrl(doc, siteUrl) {
|
|
270
|
-
const img = doc?.meta?.image ?? doc?.heroImage ?? doc?.image;
|
|
271
|
-
if (!img)
|
|
272
|
-
return null;
|
|
273
|
-
if (typeof img === "string")
|
|
274
|
-
return img;
|
|
275
|
-
if (img?.url)
|
|
276
|
-
return img.url.startsWith("http") ? img.url : `${siteUrl}${img.url}`;
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
279
|
-
function getImageUrlWithLog(doc, siteUrl) {
|
|
280
|
-
const result = getImageUrl(doc, siteUrl);
|
|
281
|
-
console.log("[WWW] render/metadata:jsonld:getImageUrl ->", result);
|
|
282
|
-
return result;
|
|
283
|
-
}
|
|
284
|
-
function resolveLocalizedField(value, locale) {
|
|
285
|
-
if (value == null)
|
|
286
|
-
return "";
|
|
287
|
-
if (typeof value === "string") {
|
|
288
|
-
if (!value.startsWith("{"))
|
|
289
|
-
return value;
|
|
290
|
-
try {
|
|
291
|
-
const parsed = JSON.parse(value);
|
|
292
|
-
return resolveLocalizedField(parsed, locale);
|
|
293
|
-
} catch {
|
|
294
|
-
return value;
|
|
63
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
64
|
+
function HeaderPage({ data }) {
|
|
65
|
+
const nav = data.nav ?? [];
|
|
66
|
+
const items = nav.filter((b) => b.blockType === "navItem");
|
|
67
|
+
const columns = nav.filter((b) => b.blockType === "navColumn");
|
|
68
|
+
const renderLink = (link, fallbackHref = "#") => {
|
|
69
|
+
if (!link)
|
|
70
|
+
return /* @__PURE__ */ jsx2("a", {
|
|
71
|
+
href: fallbackHref,
|
|
72
|
+
children: link?.label ?? ""
|
|
73
|
+
});
|
|
74
|
+
if (link.type === "custom" && typeof link.url === "string") {
|
|
75
|
+
return /* @__PURE__ */ jsx2("a", {
|
|
76
|
+
href: link.url,
|
|
77
|
+
children: link.label
|
|
78
|
+
});
|
|
295
79
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
return result;
|
|
311
|
-
}
|
|
312
|
-
function buildArticleLd({
|
|
313
|
-
doc,
|
|
314
|
-
url,
|
|
315
|
-
locale,
|
|
316
|
-
siteUrl,
|
|
317
|
-
type = "BlogPosting",
|
|
318
|
-
publisherName,
|
|
319
|
-
publisherLogo
|
|
320
|
-
}) {
|
|
321
|
-
const name = publisherName ?? new URL(siteUrl).hostname;
|
|
322
|
-
console.log("[WWW] render/metadata:buildArticleLd url=", url, "locale=", locale, "type=", type, "publisherName=", name);
|
|
323
|
-
const ld = {
|
|
324
|
-
"@context": "https://schema.org",
|
|
325
|
-
"@type": type,
|
|
326
|
-
"@id": `${url}#article`,
|
|
327
|
-
headline: resolveLocalizedFieldWithLog(doc.title, locale),
|
|
328
|
-
description: resolveLocalizedFieldWithLog(doc.meta?.description ?? doc.description ?? doc.excerpt, locale),
|
|
329
|
-
inLanguage: locale,
|
|
330
|
-
url,
|
|
331
|
-
dateModified: doc.updatedAt ? new Date(doc.updatedAt).toISOString() : undefined
|
|
332
|
-
};
|
|
333
|
-
const datePublished = doc.publishedAt ?? doc.createdAt;
|
|
334
|
-
if (datePublished)
|
|
335
|
-
ld.datePublished = new Date(datePublished).toISOString();
|
|
336
|
-
const imgUrl = getImageUrlWithLog(doc, siteUrl);
|
|
337
|
-
if (imgUrl)
|
|
338
|
-
ld.image = imgUrl;
|
|
339
|
-
ld.author = { "@type": "Organization", name, url: siteUrl };
|
|
340
|
-
const publisher = { "@type": "Organization", name };
|
|
341
|
-
if (publisherLogo !== undefined) {
|
|
342
|
-
if (publisherLogo !== null)
|
|
343
|
-
publisher.logo = { "@type": "ImageObject", url: publisherLogo };
|
|
344
|
-
}
|
|
345
|
-
ld.publisher = publisher;
|
|
346
|
-
return ld;
|
|
347
|
-
}
|
|
348
|
-
function buildBreadcrumbsLd({
|
|
349
|
-
items,
|
|
350
|
-
currentUrl
|
|
351
|
-
}) {
|
|
352
|
-
console.log("[WWW] render/metadata:buildBreadcrumbsLd items=", items.length, "currentUrl=", currentUrl);
|
|
353
|
-
return {
|
|
354
|
-
"@context": "https://schema.org",
|
|
355
|
-
"@type": "BreadcrumbList",
|
|
356
|
-
itemListElement: items.map((item, index) => ({
|
|
357
|
-
"@type": "ListItem",
|
|
358
|
-
position: index + 1,
|
|
359
|
-
name: item.label,
|
|
360
|
-
item: index === items.length - 1 ? currentUrl : item.url
|
|
361
|
-
}))
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
function buildOrganizationLd({
|
|
365
|
-
siteUrl,
|
|
366
|
-
name,
|
|
367
|
-
logo,
|
|
368
|
-
sameAs
|
|
369
|
-
}) {
|
|
370
|
-
console.log("[WWW] render/metadata:buildOrganizationLd siteUrl=", siteUrl, "name=", name, "logo?", Boolean(logo), "sameAs?", Boolean(sameAs));
|
|
371
|
-
const org = {
|
|
372
|
-
"@context": "https://schema.org",
|
|
373
|
-
"@type": "Organization",
|
|
374
|
-
"@id": `${siteUrl}#organization`,
|
|
375
|
-
url: siteUrl,
|
|
376
|
-
...name && { name },
|
|
377
|
-
...logo && { logo: { "@type": "ImageObject", url: logo } },
|
|
378
|
-
...sameAs && sameAs.length > 0 && { sameAs }
|
|
80
|
+
if (link.type === "reference" && link.reference) {
|
|
81
|
+
const ref = link.reference;
|
|
82
|
+
if (typeof ref === "object" && ref.slug) {
|
|
83
|
+
return /* @__PURE__ */ jsx2("a", {
|
|
84
|
+
href: `/${ref.slug}`,
|
|
85
|
+
children: link.label
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return /* @__PURE__ */ jsx2("a", {
|
|
90
|
+
href: fallbackHref,
|
|
91
|
+
children: link.label ?? ""
|
|
92
|
+
});
|
|
379
93
|
};
|
|
380
|
-
return
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
else
|
|
401
|
-
result = "/" + (segments[0] ?? "");
|
|
402
|
-
console.log("[WWW] render/metadata:segmentsToUrlPath nested=", nested, "segments=", JSON.stringify(segments), "->", result);
|
|
403
|
-
return result;
|
|
404
|
-
}
|
|
405
|
-
function storedSlugToSegments(storedSlug, nested) {
|
|
406
|
-
const result = nested ? storedSlug.split(SLUG_NESTED_DIVIDER) : storedSlug;
|
|
407
|
-
console.log("[WWW] render/metadata:storedSlugToSegments nested=", nested, "storedSlug=", storedSlug, "->", JSON.stringify(result));
|
|
408
|
-
return result;
|
|
409
|
-
}
|
|
410
|
-
function buildCanonicalUrl({
|
|
411
|
-
siteUrl,
|
|
412
|
-
locale,
|
|
413
|
-
urlPrefix,
|
|
414
|
-
urlPath
|
|
415
|
-
}) {
|
|
416
|
-
const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
|
|
417
|
-
const prefixSegment = trimmedPrefix ? `/${trimmedPrefix}` : "";
|
|
418
|
-
const result = `${siteUrl}/${locale}${prefixSegment}${urlPath}`;
|
|
419
|
-
console.log("[WWW] render/metadata:buildCanonicalUrl siteUrl=", siteUrl, "locale=", locale, "urlPrefix=", urlPrefix, "urlPath=", urlPath, "->", result);
|
|
420
|
-
return result;
|
|
421
|
-
}
|
|
422
|
-
function getUrlPath(segments, nested, homeSlug) {
|
|
423
|
-
const urlPath = segmentsToUrlPath(segments, nested);
|
|
424
|
-
if (nested && !Array.isArray(segments)) {
|
|
425
|
-
if (segments === homeSlug)
|
|
426
|
-
return "/";
|
|
427
|
-
} else if (nested && Array.isArray(segments)) {
|
|
428
|
-
const stored = segments.join(SLUG_NESTED_DIVIDER);
|
|
429
|
-
if (stored === homeSlug)
|
|
430
|
-
return "/";
|
|
431
|
-
}
|
|
432
|
-
return urlPath;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
// src/render/metadata/query.ts
|
|
436
|
-
import { getPayload } from "payload";
|
|
437
|
-
import { cache } from "react";
|
|
438
|
-
var queryDocBySlug = cache(async function queryDocBySlug2({
|
|
439
|
-
collectionSlug,
|
|
440
|
-
slug,
|
|
441
|
-
slugField = "slug",
|
|
442
|
-
locale,
|
|
443
|
-
draft = false,
|
|
444
|
-
config
|
|
445
|
-
}) {
|
|
446
|
-
console.log("[WWW] render/metadata:queryDocBySlug collection=", collectionSlug, "slug=", slug, "slugField=", slugField, "locale=", locale, "draft=", draft);
|
|
447
|
-
const payload = await getPayload({ config });
|
|
448
|
-
const result = await payload.find({
|
|
449
|
-
collection: collectionSlug,
|
|
450
|
-
draft,
|
|
451
|
-
limit: 1,
|
|
452
|
-
pagination: false,
|
|
453
|
-
overrideAccess: draft,
|
|
454
|
-
where: { [slugField]: { equals: slug } },
|
|
455
|
-
locale
|
|
456
|
-
});
|
|
457
|
-
const doc = result.docs?.[0] ?? null;
|
|
458
|
-
console.log("[WWW] render/metadata:queryDocBySlug ->", doc ? "hit" : "miss");
|
|
459
|
-
return doc;
|
|
460
|
-
});
|
|
461
|
-
var queryAllDocs = cache(async function queryAllDocs2({
|
|
462
|
-
collectionSlug,
|
|
463
|
-
slugField = "slug",
|
|
464
|
-
locale,
|
|
465
|
-
config
|
|
466
|
-
}) {
|
|
467
|
-
console.log("[WWW] render/metadata:queryAllDocs collection=", collectionSlug, "locale=", locale);
|
|
468
|
-
const payload = await getPayload({ config });
|
|
469
|
-
const result = await payload.find({
|
|
470
|
-
collection: collectionSlug,
|
|
471
|
-
draft: false,
|
|
472
|
-
limit: 1000,
|
|
473
|
-
pagination: false,
|
|
474
|
-
overrideAccess: false,
|
|
475
|
-
select: { [slugField]: true },
|
|
476
|
-
locale
|
|
477
|
-
});
|
|
478
|
-
const docs = result.docs ?? [];
|
|
479
|
-
console.log("[WWW] render/metadata:queryAllDocs -> count=", docs.length);
|
|
480
|
-
return docs;
|
|
481
|
-
});
|
|
482
|
-
var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
483
|
-
collectionSlug,
|
|
484
|
-
slug,
|
|
485
|
-
slugField = "slug",
|
|
486
|
-
locale,
|
|
487
|
-
config
|
|
488
|
-
}) {
|
|
489
|
-
console.log("[WWW] render/metadata:queryAllLocaleSlugs collection=", collectionSlug, "slug=", slug, "locale=", locale);
|
|
490
|
-
const payload = await getPayload({ config });
|
|
491
|
-
const result = await payload.find({
|
|
492
|
-
collection: collectionSlug,
|
|
493
|
-
draft: false,
|
|
494
|
-
limit: 1,
|
|
495
|
-
pagination: false,
|
|
496
|
-
overrideAccess: false,
|
|
497
|
-
locale,
|
|
498
|
-
where: { [slugField]: { equals: slug } },
|
|
499
|
-
select: { [slugField]: true }
|
|
94
|
+
return /* @__PURE__ */ jsxs2("nav", {
|
|
95
|
+
children: [
|
|
96
|
+
items.map((item, i) => /* @__PURE__ */ jsx2("span", {
|
|
97
|
+
style: { marginRight: 16 },
|
|
98
|
+
children: renderLink(item.link)
|
|
99
|
+
}, `item-${i}`)),
|
|
100
|
+
columns.map((col, i) => /* @__PURE__ */ jsxs2("div", {
|
|
101
|
+
style: { display: "inline-block", marginRight: 24, verticalAlign: "top" },
|
|
102
|
+
children: [
|
|
103
|
+
col.title ? /* @__PURE__ */ jsx2("strong", {
|
|
104
|
+
children: col.title
|
|
105
|
+
}) : null,
|
|
106
|
+
/* @__PURE__ */ jsx2("div", {
|
|
107
|
+
children: (col.links ?? []).map((entry, j) => /* @__PURE__ */ jsx2("div", {
|
|
108
|
+
children: renderLink(entry.link)
|
|
109
|
+
}, `col-${i}-link-${j}`))
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
}, `col-${i}`))
|
|
113
|
+
]
|
|
500
114
|
});
|
|
501
|
-
const doc = result.docs?.[0];
|
|
502
|
-
if (!doc) {
|
|
503
|
-
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> undefined (no doc)");
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
|
-
let fieldValue = doc[slugField];
|
|
507
|
-
if (doc.id != null) {
|
|
508
|
-
const allLocales = await payload.findByID({
|
|
509
|
-
collection: collectionSlug,
|
|
510
|
-
id: doc.id,
|
|
511
|
-
locale: "all",
|
|
512
|
-
draft: false,
|
|
513
|
-
overrideAccess: false,
|
|
514
|
-
select: { [slugField]: true }
|
|
515
|
-
}).catch(() => null);
|
|
516
|
-
if (allLocales)
|
|
517
|
-
fieldValue = allLocales[slugField];
|
|
518
|
-
}
|
|
519
|
-
if (fieldValue && typeof fieldValue === "object") {
|
|
520
|
-
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> localized map=", JSON.stringify(fieldValue));
|
|
521
|
-
return fieldValue;
|
|
522
|
-
}
|
|
523
|
-
const resolved = await config;
|
|
524
|
-
const rawLocales = Array.isArray(resolved?.localization?.localeCodes) ? resolved.localization.localeCodes : resolved?.localization?.locales?.map((l) => l.code) ?? [];
|
|
525
|
-
const out = {};
|
|
526
|
-
for (const l of rawLocales)
|
|
527
|
-
out[l] = String(fieldValue ?? slug);
|
|
528
|
-
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> flat-fanout locales=", rawLocales.length, "slug=", JSON.stringify(fieldValue ?? slug));
|
|
529
|
-
return out;
|
|
530
|
-
});
|
|
531
|
-
var queryGlobal = cache(async function queryGlobal2({
|
|
532
|
-
globalSlug,
|
|
533
|
-
locale,
|
|
534
|
-
depth = 0,
|
|
535
|
-
draft = false,
|
|
536
|
-
config
|
|
537
|
-
}) {
|
|
538
|
-
console.log("[WWW] render/metadata:queryGlobal global=", globalSlug, "locale=", locale, "depth=", depth, "draft=", draft);
|
|
539
|
-
const payload = await getPayload({ config });
|
|
540
|
-
try {
|
|
541
|
-
const global = await payload.findGlobal({
|
|
542
|
-
slug: globalSlug,
|
|
543
|
-
depth,
|
|
544
|
-
draft,
|
|
545
|
-
locale
|
|
546
|
-
});
|
|
547
|
-
console.log("[WWW] render/metadata:queryGlobal -> hit");
|
|
548
|
-
return global;
|
|
549
|
-
} catch (error) {
|
|
550
|
-
console.warn("[WWW] render/metadata:queryGlobal failed for slug=", globalSlug, "err=", String(error));
|
|
551
|
-
return null;
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
function getRenderModuleExports(exportName, collection, importMap) {
|
|
555
|
-
const path = collection?.custom?.path;
|
|
556
|
-
if (!path) {
|
|
557
|
-
console.log("[WWW] render/metadata:getRenderModuleExports no custom.path exportName=", exportName);
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
|
-
const mod = getFromImportMap(path, importMap);
|
|
561
|
-
const value = mod?.[exportName];
|
|
562
|
-
console.log("[WWW] render/metadata:getRenderModuleExports exportName=", exportName, "path=", path, "hit=", Boolean(value));
|
|
563
|
-
return value;
|
|
564
115
|
}
|
|
565
116
|
|
|
566
|
-
// src/render/
|
|
567
|
-
|
|
117
|
+
// src/render/getFromImportMap.ts
|
|
118
|
+
function getFromImportMap(key, importMap) {
|
|
119
|
+
return key && importMap[key.includes("#") ? key : key + "#default"];
|
|
120
|
+
}
|
|
568
121
|
|
|
569
|
-
// src/
|
|
122
|
+
// src/render/generateImportName.ts
|
|
570
123
|
function generateImportName(type, slug) {
|
|
571
124
|
switch (type) {
|
|
572
|
-
case "block":
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
return
|
|
576
|
-
}
|
|
577
|
-
case "page": {
|
|
578
|
-
const name = `Page${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
579
|
-
console.log("[WWW] core/utils:generateImportName type=page slug=", slug, "->", name);
|
|
580
|
-
return name;
|
|
581
|
-
}
|
|
125
|
+
case "block":
|
|
126
|
+
return `Block${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
127
|
+
case "page":
|
|
128
|
+
return `Page${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
582
129
|
default:
|
|
583
|
-
console.error("[WWW] core/utils:generateImportName unknown type:", type);
|
|
584
130
|
throw new Error(`Unknown type: ${type}`);
|
|
585
131
|
}
|
|
586
132
|
}
|
|
587
133
|
|
|
588
134
|
// src/render/blocks/renderBlocks.tsx
|
|
589
|
-
import { jsx as
|
|
135
|
+
import { jsx as jsx3, Fragment } from "react/jsx-runtime";
|
|
590
136
|
var RenderBlocks = ({
|
|
591
137
|
blocks,
|
|
592
138
|
blockProps,
|
|
@@ -604,14 +150,14 @@ var RenderBlocks = ({
|
|
|
604
150
|
for (let i = 0;i < blocks.length; i++) {
|
|
605
151
|
const block = blocks[i];
|
|
606
152
|
const { blockType } = block;
|
|
607
|
-
const importMapPath = config.admin?.dependencies?.[blockType]?.path
|
|
153
|
+
const importMapPath = config.admin?.dependencies?.[blockType]?.path || generateImportName("block", blockType);
|
|
608
154
|
const Block = getFromImportMap(importMapPath, importMap);
|
|
609
155
|
if (!Block) {
|
|
610
156
|
console.warn(`[WWW] render/blocks:RenderBlocks no block for type=${blockType} importMapPath=${importMapPath} (locale=${locale})`);
|
|
611
157
|
continue;
|
|
612
158
|
}
|
|
613
159
|
console.log("[WWW] render/blocks:RenderBlocks [", i, "] blockType=", blockType, "importMapPath=", importMapPath);
|
|
614
|
-
rendered.push(/* @__PURE__ */
|
|
160
|
+
rendered.push(/* @__PURE__ */ jsx3(Block, {
|
|
615
161
|
index: i,
|
|
616
162
|
...blockProps,
|
|
617
163
|
...block,
|
|
@@ -619,456 +165,417 @@ var RenderBlocks = ({
|
|
|
619
165
|
searchParams
|
|
620
166
|
}, i));
|
|
621
167
|
}
|
|
622
|
-
return /* @__PURE__ */
|
|
168
|
+
return /* @__PURE__ */ jsx3(Fragment, {
|
|
623
169
|
children: rendered
|
|
624
170
|
});
|
|
625
171
|
};
|
|
626
172
|
|
|
627
173
|
// src/render/pages/PagesPage.tsx
|
|
628
|
-
import { jsx as
|
|
629
|
-
async function PagesPage({
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
174
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
175
|
+
async function PagesPage({ data, locale, ...props }) {
|
|
176
|
+
const blocks = data.blocks ?? [];
|
|
177
|
+
return /* @__PURE__ */ jsx4(RenderBlocks, {
|
|
178
|
+
blocks,
|
|
179
|
+
locale,
|
|
180
|
+
...props
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// src/render/pages/PostsPage.tsx
|
|
185
|
+
import { RichText } from "@payloadcms/richtext-lexical/react";
|
|
186
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
187
|
+
async function PostsPage({ doc, locale, ...props }) {
|
|
188
|
+
return /* @__PURE__ */ jsxs3("article", {
|
|
189
|
+
className: "posts-page prose prose-neutral dark:prose-invert mx-auto max-w-3xl py-10",
|
|
190
|
+
children: [
|
|
191
|
+
/* @__PURE__ */ jsxs3("header", {
|
|
192
|
+
className: "posts-page__header not-prose mb-8",
|
|
193
|
+
children: [
|
|
194
|
+
/* @__PURE__ */ jsx5("h1", {
|
|
195
|
+
className: "posts-page__title text-4xl font-semibold tracking-tight",
|
|
196
|
+
children: doc.title
|
|
197
|
+
}),
|
|
198
|
+
doc.excerpt && /* @__PURE__ */ jsx5("p", {
|
|
199
|
+
className: "posts-page__excerpt mt-3 text-lg text-muted-foreground",
|
|
200
|
+
children: doc.excerpt
|
|
201
|
+
})
|
|
202
|
+
]
|
|
203
|
+
}),
|
|
204
|
+
doc.content && /* @__PURE__ */ jsx5("div", {
|
|
205
|
+
className: "posts-page__content",
|
|
206
|
+
children: /* @__PURE__ */ jsx5(RichText, {
|
|
207
|
+
data: doc.content
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
]
|
|
641
211
|
});
|
|
642
212
|
}
|
|
643
213
|
|
|
644
214
|
// src/render/pages/createCollectionPageExports.tsx
|
|
645
|
-
import
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
const
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
215
|
+
import"server-only";
|
|
216
|
+
|
|
217
|
+
// src/render/metadata/slug.ts
|
|
218
|
+
var SLUG_NESTED_DIVIDER = "_";
|
|
219
|
+
function paramsSlugToSlug(slug, _shape) {
|
|
220
|
+
if (!slug)
|
|
221
|
+
return "";
|
|
222
|
+
return (Array.isArray(slug) ? slug : [slug]).join(SLUG_NESTED_DIVIDER);
|
|
223
|
+
}
|
|
224
|
+
function slugToParamsSlug(slug, shape) {
|
|
225
|
+
if (!slug)
|
|
226
|
+
return shape === "catch-all" ? [] : "";
|
|
227
|
+
return shape === "catch-all" ? slug.split(SLUG_NESTED_DIVIDER) : slug;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// src/render/metadata/query.ts
|
|
231
|
+
import { getPayload } from "payload";
|
|
232
|
+
|
|
233
|
+
// src/collections/hooks/createRevalidateCollectionGlobalHook.ts
|
|
234
|
+
import { revalidateTag } from "next/cache";
|
|
235
|
+
function createRevalidateCollectionGlobalHook() {
|
|
236
|
+
const afterChangeDeleteHook = async ({ doc, req, ...args }) => {
|
|
237
|
+
const previousDoc = "previousDoc" in args ? args.previousDoc : null, locale = req.locale;
|
|
238
|
+
function revalidate(args2) {
|
|
239
|
+
try {
|
|
240
|
+
revalidateTag(createCollectionCacheKey({ ...args2, locale }), "max");
|
|
241
|
+
} catch (error) {
|
|
242
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
243
|
+
if (msg.includes("static generation store missing"))
|
|
244
|
+
return;
|
|
245
|
+
console.error(error);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if ("collection" in args) {
|
|
249
|
+
[
|
|
250
|
+
doc && doc._status !== "draft" && doc.slug,
|
|
251
|
+
previousDoc && previousDoc._status === "published" && previousDoc.slug
|
|
252
|
+
].filter((slug) => slug !== undefined && slug !== false).map((slug) => revalidate({ collectionSlug: args.collection.slug, slug }));
|
|
253
|
+
} else {
|
|
254
|
+
revalidate({ globalSlug: args.global.slug });
|
|
255
|
+
}
|
|
256
|
+
return doc;
|
|
682
257
|
};
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
258
|
+
return { afterChange: afterChangeDeleteHook, afterDelete: afterChangeDeleteHook };
|
|
259
|
+
}
|
|
260
|
+
function createCollectionCacheKey(args) {
|
|
261
|
+
return `${"globalSlug" in args ? args.globalSlug : args.collectionSlug + args.slug}_${args.locale}`;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// src/render/metadata/query.ts
|
|
265
|
+
async function withUnstableCache(keyParts, tags, fn) {
|
|
266
|
+
const { unstable_cache } = await import("next/cache");
|
|
267
|
+
return unstable_cache(fn, keyParts.map(String), { tags })();
|
|
268
|
+
}
|
|
269
|
+
async function queryDoc(args, { config: configPromise }) {
|
|
270
|
+
return withUnstableCache(Object.values(args), [createCollectionCacheKey(args)], async () => {
|
|
271
|
+
if ("globalSlug" in args)
|
|
272
|
+
return queryGlobal({ ...args, config: configPromise });
|
|
273
|
+
else
|
|
274
|
+
return queryDocBySlug({ ...args, config: configPromise });
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
async function queryDocBySlug({
|
|
278
|
+
collectionSlug,
|
|
279
|
+
slug,
|
|
280
|
+
slugField = "slug",
|
|
281
|
+
locale,
|
|
282
|
+
draft = false,
|
|
283
|
+
config
|
|
284
|
+
}) {
|
|
285
|
+
return withUnstableCache([collectionSlug, slug, locale, draft], [createCollectionCacheKey({ collectionSlug, slug, locale })], async () => {
|
|
286
|
+
const payload = await getPayload({ config });
|
|
287
|
+
const result = await payload.find({
|
|
288
|
+
collection: collectionSlug,
|
|
289
|
+
draft,
|
|
290
|
+
limit: 1,
|
|
291
|
+
pagination: false,
|
|
292
|
+
overrideAccess: draft,
|
|
293
|
+
where: { [slugField]: { equals: slug } },
|
|
294
|
+
locale
|
|
295
|
+
});
|
|
296
|
+
return result.docs?.[0] ?? null;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
async function queryGlobal({
|
|
300
|
+
globalSlug,
|
|
301
|
+
locale,
|
|
302
|
+
draft = false,
|
|
303
|
+
config
|
|
304
|
+
}) {
|
|
305
|
+
return withUnstableCache([globalSlug, locale, draft], [createCollectionCacheKey({ globalSlug, locale })], async () => {
|
|
306
|
+
const payload = await getPayload({ config });
|
|
307
|
+
try {
|
|
308
|
+
return await payload.findGlobal({ slug: globalSlug, draft, locale });
|
|
309
|
+
} catch (error) {
|
|
310
|
+
console.warn("[WWW] queryGlobal failed", { globalSlug, locale, error: String(error) });
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
async function queryAllDocs({
|
|
316
|
+
collectionSlug,
|
|
317
|
+
slugField = "slug",
|
|
318
|
+
locale,
|
|
319
|
+
config
|
|
320
|
+
}) {
|
|
321
|
+
return withUnstableCache([collectionSlug, slugField, locale], [createCollectionCacheKey({ collectionSlug, slug: "__all__", locale })], async () => {
|
|
322
|
+
const payload = await getPayload({ config });
|
|
323
|
+
const result = await payload.find({
|
|
324
|
+
collection: collectionSlug,
|
|
325
|
+
draft: false,
|
|
326
|
+
limit: 1000,
|
|
327
|
+
pagination: false,
|
|
328
|
+
overrideAccess: false,
|
|
329
|
+
select: { [slugField]: true },
|
|
330
|
+
locale
|
|
331
|
+
});
|
|
332
|
+
return result.docs ?? [];
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
async function queryAllLocaleSlugs({
|
|
336
|
+
collectionSlug,
|
|
337
|
+
id,
|
|
338
|
+
slugField = "slug",
|
|
339
|
+
config
|
|
340
|
+
}) {
|
|
341
|
+
const payload = await getPayload({ config });
|
|
342
|
+
const doc = await payload.findByID({
|
|
343
|
+
collection: collectionSlug,
|
|
344
|
+
id,
|
|
345
|
+
locale: "all",
|
|
346
|
+
select: { [slugField]: true }
|
|
347
|
+
});
|
|
348
|
+
return doc?.[slugField];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// src/render/pages/createCollectionPageExports.tsx
|
|
352
|
+
import { setRequestLocale } from "next-intl/server";
|
|
353
|
+
|
|
354
|
+
// src/render/pages/utils/buildLocalizedPath.ts
|
|
355
|
+
function buildLocalizedPath(locale, prefix, slug, { routing }) {
|
|
356
|
+
return `${routing.localePrefix === "never" ? "" : routing.localePrefix === "always" ? locale : routing.localePrefix === "as-needed" ? locale === routing.defaultLocale ? "" : "/" + locale : (() => {
|
|
357
|
+
throw new Error("Unsupported locale prefix");
|
|
358
|
+
})()}${prefix ? "/" + prefix : ""}${slug ? "/" + slug : ""}`;
|
|
359
|
+
}
|
|
360
|
+
function buildLocalizedPaths(localesSlug, pagePathPrefix, { routing }) {
|
|
361
|
+
return routing.locales.reduce((paths, locale) => {
|
|
362
|
+
const slug = localesSlug[locale];
|
|
363
|
+
paths[locale] = buildLocalizedPath(locale, pagePathPrefix, slug, { routing });
|
|
364
|
+
return paths;
|
|
365
|
+
}, {});
|
|
366
|
+
}
|
|
367
|
+
function buildAlternates(locale, ...args) {
|
|
368
|
+
const siteUrl = args[2].siteUrl;
|
|
369
|
+
let localizedPaths = buildLocalizedPaths(...args);
|
|
370
|
+
localizedPaths["x-default"] = localizedPaths[args[2].routing.defaultLocale];
|
|
371
|
+
localizedPaths = Object.fromEntries(Object.entries(localizedPaths).map(([key, value]) => [key, siteUrl + localizedPaths[key]]));
|
|
372
|
+
return {
|
|
373
|
+
languages: localizedPaths,
|
|
374
|
+
canonical: localizedPaths[locale]
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// src/render/pages/createCollectionPageExports.tsx
|
|
379
|
+
import { createSiteDefaults, generateMeta } from "@justanarthur/payload-plugin-seo/next-metadata";
|
|
380
|
+
|
|
381
|
+
// package.json
|
|
382
|
+
var name = "@justanarthur/payload-www";
|
|
383
|
+
|
|
384
|
+
// src/render/renderWWWModule.tsx
|
|
385
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
386
|
+
async function renderWWWDataModule(data, {
|
|
387
|
+
collectionSlug,
|
|
388
|
+
configPath = "collections",
|
|
389
|
+
config: configPromise,
|
|
390
|
+
importMap
|
|
391
|
+
}, props) {
|
|
392
|
+
const config = await configPromise;
|
|
393
|
+
const renderPath = config[configPath]?.find((c) => c.slug === collectionSlug)?.custom?.[name]?.path;
|
|
394
|
+
const RenderModule = getFromImportMap(renderPath, importMap);
|
|
395
|
+
if (!RenderModule) {
|
|
396
|
+
if (false) {}
|
|
397
|
+
return null;
|
|
691
398
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
399
|
+
return /* @__PURE__ */ jsx6(RenderModule, {
|
|
400
|
+
data,
|
|
401
|
+
config,
|
|
402
|
+
importMap,
|
|
403
|
+
...props
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// src/render/pages/createCollectionPageExports.tsx
|
|
408
|
+
import { jsx as jsx7, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
409
|
+
function createCollectionPageExports({
|
|
410
|
+
slug: collectionSlug = "pages",
|
|
411
|
+
config: configPromise,
|
|
412
|
+
importMap,
|
|
413
|
+
routing,
|
|
414
|
+
slugShape = "single"
|
|
415
|
+
}, {
|
|
416
|
+
getServerSideURL,
|
|
417
|
+
pagePathPrefix
|
|
418
|
+
}) {
|
|
419
|
+
const siteUrl = getServerSideURL();
|
|
420
|
+
async function fetchDoc(locale, slug) {
|
|
421
|
+
return queryDoc({
|
|
422
|
+
slug,
|
|
698
423
|
locale,
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
homeSlug: HOME_SLUG,
|
|
703
|
-
defaultLocale,
|
|
704
|
-
locales,
|
|
705
|
-
localePrefix: localePrefixMode,
|
|
706
|
-
queryAllLocaleSlugs: (s, l) => queryAllLocaleSlugs({ collectionSlug: slug, slug: s, slugField: "slug", locale: l, config: configPromise })
|
|
424
|
+
collectionSlug
|
|
425
|
+
}, {
|
|
426
|
+
config: configPromise
|
|
707
427
|
});
|
|
708
|
-
const alternates = {};
|
|
709
|
-
for (const [key, url] of Object.entries(languages)) {
|
|
710
|
-
alternates[key] = url;
|
|
711
|
-
}
|
|
712
|
-
console.log("[WWW] render/pages:createCollectionPageExports:resolveHreflangAlternates canonical=", canonical, "alts=", JSON.stringify(alternates));
|
|
713
|
-
return { alternates, canonical };
|
|
714
428
|
}
|
|
715
429
|
const default_ = async (props) => {
|
|
716
|
-
const
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
console.log("[WWW] render/pages:createCollectionPageExports:default_ collectionSlug=", slug, "locale=", locale, "segments=", JSON.stringify(slugSegments), "showcase=", showcaseEnabled);
|
|
720
|
-
if (!locales.includes(locale)) {
|
|
721
|
-
console.error(`[WWW] render/pages:createCollectionPageExports:default_ notFound invalid-locale collection=${slug} locale=${locale} segments=${JSON.stringify(slugSegments)}`);
|
|
430
|
+
const params = await props.params;
|
|
431
|
+
const locale = params.locale;
|
|
432
|
+
if (!routing.locales.includes(locale)) {
|
|
722
433
|
const { notFound } = await import("next/navigation");
|
|
723
|
-
notFound();
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
const
|
|
728
|
-
const { isEnabled: draft } = await draftMode();
|
|
729
|
-
console.log("[WWW] render/pages:createCollectionPageExports:default_ draftMode=", draft);
|
|
730
|
-
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
731
|
-
const doc = await fetchDoc(locale, storedSlug, draft);
|
|
434
|
+
return notFound();
|
|
435
|
+
} else
|
|
436
|
+
setRequestLocale(locale);
|
|
437
|
+
const slug = paramsSlugToSlug(params.slug, slugShape);
|
|
438
|
+
const doc = await fetchDoc(locale, slug);
|
|
732
439
|
if (!doc) {
|
|
733
|
-
console.error(`[WWW] render/pages:createCollectionPageExports:default_ notFound no-doc collection=${slug} locale=${locale} storedSlug="${storedSlug}" segments=${JSON.stringify(slugSegments)} draft=${draft}`);
|
|
734
440
|
const { notFound } = await import("next/navigation");
|
|
735
441
|
notFound();
|
|
736
442
|
}
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
console.log("[WWW] render/pages:createCollectionPageExports:default_ effectivePath=", effectivePath);
|
|
741
|
-
const render = effectivePath === PAGES_RENDER_PATH ? /* @__PURE__ */ jsx6(PagesPage, {
|
|
742
|
-
doc,
|
|
743
|
-
importMap,
|
|
744
|
-
config: cfg,
|
|
745
|
-
locale
|
|
746
|
-
}) : effectivePath === POSTS_RENDER_PATH ? doc ? await renderPostBody(doc, locale) : null : renderCollectionModule(cfg.collections, slug, importMap, {
|
|
747
|
-
...props,
|
|
748
|
-
config: cfg,
|
|
749
|
-
locale,
|
|
750
|
-
searchParams: props.searchParams,
|
|
751
|
-
doc
|
|
752
|
-
});
|
|
753
|
-
const jsonLdNodes = doc ? await generateJsonLd(slugSegments, doc, locale) : [];
|
|
754
|
-
const { alternates: hreflangAlternates, canonical } = await resolveHreflangAlternates(locale, storedSlug);
|
|
755
|
-
const inner = /* @__PURE__ */ jsxs3(Fragment4, {
|
|
756
|
-
children: [
|
|
757
|
-
jsonLdNodes.map(({ id, schema }) => /* @__PURE__ */ jsx6("script", {
|
|
758
|
-
type: "application/ld+json",
|
|
759
|
-
dangerouslySetInnerHTML: { __html: JSON.stringify(schema) }
|
|
760
|
-
}, id)),
|
|
761
|
-
render,
|
|
762
|
-
draft ? (() => {
|
|
763
|
-
const ResolvedListener = importMap?.[LIVE_PREVIEW_LISTENER_PATH];
|
|
764
|
-
if (!ResolvedListener)
|
|
765
|
-
return null;
|
|
766
|
-
return /* @__PURE__ */ jsx6(Suspense, {
|
|
767
|
-
fallback: null,
|
|
768
|
-
children: /* @__PURE__ */ jsx6(ResolvedListener, {})
|
|
769
|
-
});
|
|
770
|
-
})() : null,
|
|
771
|
-
storedSlug === HOME_SLUG && homeExtras ? await homeExtras({ locale, doc }) : null
|
|
772
|
-
]
|
|
773
|
-
});
|
|
774
|
-
if (!showcaseEnabled || !doc)
|
|
775
|
-
return inner;
|
|
776
|
-
const { PageShowcase: PageShowcase2 } = await Promise.resolve().then(() => (init_PageShowcase(), exports_PageShowcase));
|
|
777
|
-
const { LocaleSwitcher: LocaleSwitcher2 } = await Promise.resolve().then(() => (init_LocaleSwitcher(), exports_LocaleSwitcher));
|
|
778
|
-
const meta = await generateMeta({
|
|
779
|
-
doc,
|
|
780
|
-
url: canonical,
|
|
781
|
-
type: metadataType,
|
|
782
|
-
locale
|
|
783
|
-
});
|
|
784
|
-
return /* @__PURE__ */ jsx6(PageShowcase2, {
|
|
785
|
-
metadata: meta,
|
|
786
|
-
metadataHeading,
|
|
787
|
-
jsonLdHeading,
|
|
788
|
-
jsonLd: jsonLdNodes,
|
|
789
|
-
localeSwitcher: /* @__PURE__ */ jsx6(LocaleSwitcher2, {
|
|
790
|
-
currentLocale: locale,
|
|
791
|
-
hreflangAlternates,
|
|
792
|
-
labels: routing.labels
|
|
793
|
-
}),
|
|
794
|
-
children: inner
|
|
443
|
+
const rendered = renderWWWDataModule(doc, { collectionSlug, config: configPromise, importMap }, { ...props, locale });
|
|
444
|
+
return /* @__PURE__ */ jsx7(Fragment2, {
|
|
445
|
+
children: rendered
|
|
795
446
|
});
|
|
796
447
|
};
|
|
797
448
|
async function generateMetadata(props) {
|
|
798
|
-
const
|
|
799
|
-
const
|
|
800
|
-
const
|
|
801
|
-
const
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
if (!doc)
|
|
810
|
-
console.log("[WWW] render/pages:createCollectionPageExports:generateMetadata no doc -> not found meta");
|
|
811
|
-
return { title: "Not found", robots: { index: false, follow: false } };
|
|
812
|
-
}
|
|
813
|
-
const collection = cfg.collections.find((c) => c.slug === slug);
|
|
814
|
-
if (!collection) {
|
|
815
|
-
console.warn("[WWW] render/pages:createCollectionPageExports:generateMetadata collection not in config slug=", slug);
|
|
449
|
+
const params = await props.params;
|
|
450
|
+
const locale = params.locale, slug = paramsSlugToSlug(params.slug, slugShape);
|
|
451
|
+
const doc = await fetchDoc(locale, slug);
|
|
452
|
+
const [localesSlug, siteDefaults] = await Promise.all([
|
|
453
|
+
doc ? queryAllLocaleSlugs({
|
|
454
|
+
id: doc.id,
|
|
455
|
+
collectionSlug,
|
|
456
|
+
config: configPromise
|
|
457
|
+
}) : Promise.resolve({}),
|
|
458
|
+
createSiteDefaults({ config: configPromise, locale })
|
|
459
|
+
]);
|
|
460
|
+
if (!doc)
|
|
816
461
|
return {};
|
|
817
|
-
}
|
|
818
|
-
const { canonical, alternates } = await resolveHreflangAlternates(locale, storedSlug);
|
|
462
|
+
const alternates = buildAlternates(locale, localesSlug ?? {}, pagePathPrefix, { routing, siteUrl });
|
|
819
463
|
const meta = await generateMeta({
|
|
820
|
-
doc,
|
|
821
|
-
url: canonical,
|
|
822
|
-
type:
|
|
823
|
-
locale
|
|
464
|
+
meta: doc.meta,
|
|
465
|
+
url: alternates.canonical,
|
|
466
|
+
type: "website",
|
|
467
|
+
locale,
|
|
468
|
+
availableLocales: routing.locales,
|
|
469
|
+
fallback: doc,
|
|
470
|
+
siteDefaults
|
|
824
471
|
});
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
languages: Object.keys(alternates).length ? alternates : undefined
|
|
828
|
-
};
|
|
829
|
-
return meta;
|
|
472
|
+
console.log("[www#generateMetadata]", { alternates, meta, locale, localesSlug, doc });
|
|
473
|
+
return { ...meta, alternates };
|
|
830
474
|
}
|
|
831
|
-
async function
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
836
|
-
const urlPath = buildLocalePath(locale, storedSlug);
|
|
837
|
-
const canonical = `${siteUrl}${urlPath}`;
|
|
838
|
-
const entries = Array.isArray(jsonLdOption) ? jsonLdOption : metadataType === "article" ? [{ type: "article" }] : [{ type: "website" }];
|
|
839
|
-
console.log("[WWW] render/pages:createCollectionPageExports:generateJsonLd collection=", slug, "locale=", locale, "entries=", entries.map((e) => e.type).join(","));
|
|
840
|
-
const outputs = [];
|
|
841
|
-
for (const entry of entries) {
|
|
842
|
-
const id = entry.id ?? `jsonld-${entry.type}-${outputs.length}`;
|
|
843
|
-
let schema = null;
|
|
844
|
-
switch (entry.type) {
|
|
845
|
-
case "article": {
|
|
846
|
-
const articleOpts = {
|
|
847
|
-
doc,
|
|
848
|
-
url: canonical,
|
|
849
|
-
locale,
|
|
850
|
-
siteUrl,
|
|
851
|
-
type: entry.schemaType ?? "BlogPosting"
|
|
852
|
-
};
|
|
853
|
-
if (entry.publisherName !== undefined)
|
|
854
|
-
articleOpts.publisherName = entry.publisherName;
|
|
855
|
-
if (entry.publisherLogo !== undefined)
|
|
856
|
-
articleOpts.publisherLogo = entry.publisherLogo;
|
|
857
|
-
schema = buildArticleLd(articleOpts);
|
|
858
|
-
break;
|
|
859
|
-
}
|
|
860
|
-
case "website": {
|
|
861
|
-
schema = {
|
|
862
|
-
"@context": "https://schema.org",
|
|
863
|
-
"@type": "WebSite",
|
|
864
|
-
"@id": `${siteUrl}#website`,
|
|
865
|
-
url: siteUrl,
|
|
866
|
-
name: entry.name ?? websiteName ?? new URL(siteUrl).hostname,
|
|
867
|
-
...entry.alternateName ? { alternateName: entry.alternateName } : {},
|
|
868
|
-
inLanguage: locale
|
|
869
|
-
};
|
|
870
|
-
break;
|
|
871
|
-
}
|
|
872
|
-
case "organization": {
|
|
873
|
-
schema = buildOrganizationLd({
|
|
874
|
-
siteUrl,
|
|
875
|
-
name: entry.name,
|
|
876
|
-
logo: entry.logo,
|
|
877
|
-
sameAs: entry.sameAs
|
|
878
|
-
});
|
|
879
|
-
break;
|
|
880
|
-
}
|
|
881
|
-
case "breadcrumbs": {
|
|
882
|
-
let items = entry.items ?? [];
|
|
883
|
-
if (!items.length && entry.buildItems)
|
|
884
|
-
items = entry.buildItems(doc, canonical);
|
|
885
|
-
if (items.length > 0)
|
|
886
|
-
schema = buildBreadcrumbsLd({ items, currentUrl: canonical });
|
|
887
|
-
break;
|
|
888
|
-
}
|
|
889
|
-
case "custom": {
|
|
890
|
-
schema = entry.build({ doc, url: canonical, locale, siteUrl });
|
|
891
|
-
break;
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
if (schema)
|
|
895
|
-
outputs.push({ id, schema });
|
|
896
|
-
}
|
|
897
|
-
return outputs;
|
|
898
|
-
}
|
|
899
|
-
async function generateStaticParams() {
|
|
900
|
-
console.log("[WWW] render/pages:createCollectionPageExports:generateStaticParams collection=", slug, "locales=", JSON.stringify(locales));
|
|
901
|
-
const params = [];
|
|
902
|
-
for (const locale of locales) {
|
|
903
|
-
const docs = await queryAllDocs({ collectionSlug: slug, slugField: "slug", locale, config: configPromise });
|
|
904
|
-
for (const doc of docs) {
|
|
905
|
-
const slugVal = doc.slug;
|
|
906
|
-
if (typeof slugVal !== "string" || slugVal === "")
|
|
907
|
-
continue;
|
|
908
|
-
const segments = storedSlugToSegments(slugVal, nested);
|
|
909
|
-
params.push({ slug: Array.isArray(segments) ? segments : [segments], locale });
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
console.log("[WWW] render/pages:createCollectionPageExports:generateStaticParams -> count=", params.length);
|
|
913
|
-
return params;
|
|
475
|
+
async function generateStaticParams(props) {
|
|
476
|
+
const locale = (await props.params).locale;
|
|
477
|
+
const docs = await queryAllDocs({ locale, collectionSlug, config: configPromise });
|
|
478
|
+
return docs.filter((doc) => typeof doc.slug === "string" && doc.slug.length > 0).map((doc) => ({ slug: slugToParamsSlug(doc.slug, slugShape) }));
|
|
914
479
|
}
|
|
915
480
|
async function generateSitemap() {
|
|
916
|
-
|
|
481
|
+
const locale = routing.defaultLocale;
|
|
917
482
|
const docs = await queryAllDocs({
|
|
918
|
-
collectionSlug
|
|
919
|
-
|
|
920
|
-
locale: defaultLocale,
|
|
483
|
+
collectionSlug,
|
|
484
|
+
locale,
|
|
921
485
|
config: configPromise
|
|
922
486
|
});
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
487
|
+
return await Promise.all(docs.map(async (doc) => {
|
|
488
|
+
const localesSlug = await queryAllLocaleSlugs({
|
|
489
|
+
id: doc.id,
|
|
490
|
+
collectionSlug,
|
|
491
|
+
config: configPromise
|
|
492
|
+
}) ?? {};
|
|
493
|
+
const alternates = buildAlternates(locale, localesSlug, pagePathPrefix, { routing, siteUrl });
|
|
494
|
+
return {
|
|
495
|
+
url: alternates.canonical,
|
|
496
|
+
alternates,
|
|
497
|
+
lastModified: doc.updatedAt || new Date
|
|
498
|
+
};
|
|
499
|
+
}));
|
|
500
|
+
}
|
|
501
|
+
generateSitemap.getServerSideURL = getServerSideURL;
|
|
502
|
+
generateSitemap.pagePathPrefix = pagePathPrefix;
|
|
939
503
|
return {
|
|
940
504
|
default: default_,
|
|
941
505
|
generateMetadata,
|
|
942
506
|
generateStaticParams,
|
|
943
|
-
generateSitemap
|
|
944
|
-
generateJsonLd
|
|
507
|
+
generateSitemap
|
|
945
508
|
};
|
|
946
509
|
}
|
|
947
|
-
function
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
className: "posts-page prose prose-neutral dark:prose-invert mx-auto max-w-3xl py-10",
|
|
961
|
-
children: [
|
|
962
|
-
/* @__PURE__ */ jsxs3("header", {
|
|
963
|
-
className: "posts-page__header not-prose mb-8",
|
|
964
|
-
children: [
|
|
965
|
-
/* @__PURE__ */ jsx6("h1", {
|
|
966
|
-
className: "posts-page__title text-4xl font-semibold tracking-tight",
|
|
967
|
-
children: title
|
|
968
|
-
}),
|
|
969
|
-
excerpt ? /* @__PURE__ */ jsx6("p", {
|
|
970
|
-
className: "posts-page__excerpt mt-3 text-lg text-muted-foreground",
|
|
971
|
-
children: excerpt
|
|
972
|
-
}) : null
|
|
973
|
-
]
|
|
974
|
-
}),
|
|
975
|
-
content ? /* @__PURE__ */ jsx6("div", {
|
|
976
|
-
className: "posts-page__content",
|
|
977
|
-
children: /* @__PURE__ */ jsx6(RichText, {
|
|
978
|
-
data: content
|
|
979
|
-
})
|
|
980
|
-
}) : null
|
|
981
|
-
]
|
|
982
|
-
});
|
|
510
|
+
function createSitemapFromCollections(...args) {
|
|
511
|
+
const baseUrl = args[0].getServerSideURL();
|
|
512
|
+
return function sitemap() {
|
|
513
|
+
const sitemaps = args.map((arg) => `${baseUrl}/${arg.pagePathPrefix}/sitemap.xml`);
|
|
514
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
515
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
516
|
+
${sitemaps.map((url) => ` <sitemap><loc>${url}</loc></sitemap>`).join(`
|
|
517
|
+
`)}
|
|
518
|
+
</sitemapindex>`;
|
|
519
|
+
return new Response(xml, {
|
|
520
|
+
headers: { "Content-Type": "application/xml" }
|
|
521
|
+
});
|
|
522
|
+
};
|
|
983
523
|
}
|
|
984
524
|
|
|
985
525
|
// src/render/pages/createRootLayoutExports.tsx
|
|
986
526
|
import"server-only";
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
import {
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
return /* @__PURE__ */ jsx7(GlobalRenderModule, {
|
|
1004
|
-
importMap,
|
|
1005
|
-
...props
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
// src/render/pages/createRootLayoutExports.tsx
|
|
1010
|
-
import { jsx as jsx8, jsxs as jsxs4, Fragment as Fragment5 } from "react/jsx-runtime";
|
|
1011
|
-
function createRootLayoutExports(args) {
|
|
1012
|
-
const { config: configPromise, routing, importMap = {}, providers, head, htmlAttrs } = args;
|
|
1013
|
-
async function RootLayout({
|
|
1014
|
-
children,
|
|
1015
|
-
params
|
|
1016
|
-
}) {
|
|
1017
|
-
const { locale } = await params;
|
|
1018
|
-
console.log("[WWW] render/pages:createRootLayoutExports:RootLayout locale=", locale);
|
|
527
|
+
import { setRequestLocale as setRequestLocale2 } from "next-intl/server";
|
|
528
|
+
import { NextIntlClientProvider } from "next-intl";
|
|
529
|
+
import { RootJsonLd } from "@justanarthur/payload-plugin-seo/root-jsonld";
|
|
530
|
+
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
531
|
+
function createRootLayoutExports({
|
|
532
|
+
config: configPromise,
|
|
533
|
+
importMap,
|
|
534
|
+
routing
|
|
535
|
+
}, {
|
|
536
|
+
providers,
|
|
537
|
+
htmlAttrs,
|
|
538
|
+
getServerSideURL
|
|
539
|
+
} = {}) {
|
|
540
|
+
async function RootLayout(props) {
|
|
541
|
+
const params = await props.params;
|
|
542
|
+
const locale = params.locale;
|
|
1019
543
|
if (!routing.locales.includes(locale)) {
|
|
1020
|
-
console.error("[WWW] render/pages:createRootLayoutExports:RootLayout invalid locale=", locale);
|
|
1021
544
|
const { notFound } = await import("next/navigation");
|
|
1022
|
-
notFound();
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
const [headerData, footerData] = await Promise.all([
|
|
1032
|
-
queryGlobal({ globalSlug: "header", locale, depth: 0, config: configPromise }),
|
|
1033
|
-
queryGlobal({ globalSlug: "footer", locale, depth: 0, config: configPromise })
|
|
545
|
+
return notFound();
|
|
546
|
+
} else
|
|
547
|
+
setRequestLocale2(locale);
|
|
548
|
+
const [
|
|
549
|
+
header,
|
|
550
|
+
footer
|
|
551
|
+
] = await Promise.all([
|
|
552
|
+
queryDoc({ globalSlug: "header", locale }, { config: configPromise }),
|
|
553
|
+
queryDoc({ globalSlug: "footer", locale }, { config: configPromise })
|
|
1034
554
|
]);
|
|
1035
|
-
|
|
1036
|
-
const headerEl = renderGlobalModule(cfg.globals, "header", importMap, {
|
|
1037
|
-
data: headerData,
|
|
1038
|
-
locale
|
|
1039
|
-
});
|
|
1040
|
-
const footerEl = renderGlobalModule(cfg.globals, "footer", importMap, {
|
|
1041
|
-
data: footerData,
|
|
1042
|
-
locale
|
|
1043
|
-
});
|
|
1044
|
-
const htmlAttributeOverrides = htmlAttrs?.(locale) ?? {};
|
|
555
|
+
const renderedHeader = renderWWWDataModule(header, { collectionSlug: "header", configPath: "globals", config: configPromise, importMap }, { ...props, locale }), renderedFooter = renderWWWDataModule(footer, { collectionSlug: "footer", configPath: "globals", config: configPromise, importMap }, { ...props, locale });
|
|
1045
556
|
const mergedHtmlAttrs = {
|
|
1046
557
|
lang: locale,
|
|
1047
558
|
suppressHydrationWarning: true,
|
|
1048
|
-
...
|
|
559
|
+
...htmlAttrs?.(locale) ?? {}
|
|
1049
560
|
};
|
|
1050
|
-
const
|
|
1051
|
-
|
|
1052
|
-
children: [
|
|
1053
|
-
headerEl,
|
|
1054
|
-
children,
|
|
1055
|
-
footerEl
|
|
1056
|
-
]
|
|
1057
|
-
}),
|
|
561
|
+
const rootJsonLd = getServerSideURL ? /* @__PURE__ */ jsx8(RootJsonLd, {
|
|
562
|
+
config: configPromise,
|
|
1058
563
|
locale,
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
};
|
|
1062
|
-
return /* @__PURE__ */
|
|
564
|
+
getServerSideURL,
|
|
565
|
+
locales: routing.locales
|
|
566
|
+
}) : null;
|
|
567
|
+
return /* @__PURE__ */ jsx8("html", {
|
|
1063
568
|
...mergedHtmlAttrs,
|
|
1064
|
-
children:
|
|
1065
|
-
/* @__PURE__ */
|
|
1066
|
-
children:
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
569
|
+
children: /* @__PURE__ */ jsx8("body", {
|
|
570
|
+
children: /* @__PURE__ */ jsxs4(NextIntlClientProvider, {
|
|
571
|
+
children: [
|
|
572
|
+
rootJsonLd,
|
|
573
|
+
renderedHeader,
|
|
574
|
+
providers ? providers({ children: props.children, locale }) : props.children,
|
|
575
|
+
renderedFooter
|
|
576
|
+
]
|
|
1070
577
|
})
|
|
1071
|
-
|
|
578
|
+
})
|
|
1072
579
|
});
|
|
1073
580
|
}
|
|
1074
581
|
return {
|
|
@@ -1077,550 +584,17 @@ function createRootLayoutExports(args) {
|
|
|
1077
584
|
};
|
|
1078
585
|
}
|
|
1079
586
|
|
|
1080
|
-
// src/render/pages/createStaticPageExports.tsx
|
|
1081
|
-
import"server-only";
|
|
1082
|
-
|
|
1083
|
-
// src/core/access/index.ts
|
|
1084
|
-
var anyone = () => {
|
|
1085
|
-
console.log("[WWW] core/access:anyone -> true");
|
|
1086
|
-
return true;
|
|
1087
|
-
};
|
|
1088
|
-
var authenticated = ({ req: { user } }) => {
|
|
1089
|
-
const result = Boolean(user);
|
|
1090
|
-
console.log("[WWW] core/access:authenticated ->", result);
|
|
1091
|
-
return result;
|
|
1092
|
-
};
|
|
1093
|
-
var authenticatedOrPublished = ({ req: { user } }) => {
|
|
1094
|
-
if (user) {
|
|
1095
|
-
console.log("[WWW] core/access:authenticatedOrPublished -> true (authenticated)");
|
|
1096
|
-
return true;
|
|
1097
|
-
}
|
|
1098
|
-
console.log('[WWW] core/access:authenticatedOrPublished -> { _status: { equals: "published" } }');
|
|
1099
|
-
return { _status: { equals: "published" } };
|
|
1100
|
-
};
|
|
1101
|
-
|
|
1102
|
-
// src/render/_locale.ts
|
|
1103
|
-
function prefixFor(locale, defaultLocale, mode) {
|
|
1104
|
-
let result;
|
|
1105
|
-
if (mode === "never")
|
|
1106
|
-
result = "";
|
|
1107
|
-
else if (mode === "as-needed" && locale === defaultLocale)
|
|
1108
|
-
result = "";
|
|
1109
|
-
else
|
|
1110
|
-
result = `/${locale}`;
|
|
1111
|
-
console.log("[WWW] render/_locale:prefixFor locale=", locale, "default=", defaultLocale, "mode=", mode, "->", JSON.stringify(result));
|
|
1112
|
-
return result;
|
|
1113
|
-
}
|
|
1114
|
-
function resolveLocale(req) {
|
|
1115
|
-
if (!req || typeof req !== "object") {
|
|
1116
|
-
console.log('[WWW] render/_locale:resolveLocale -> "" (no req)');
|
|
1117
|
-
return "";
|
|
1118
|
-
}
|
|
1119
|
-
const r = req;
|
|
1120
|
-
if (typeof r.locale === "string" && r.locale.length > 0) {
|
|
1121
|
-
console.log("[WWW] render/_locale:resolveLocale ->", r.locale, "(from req.locale)");
|
|
1122
|
-
return r.locale;
|
|
1123
|
-
}
|
|
1124
|
-
const fallback = r.payload?.config?.localization?.defaultLocale;
|
|
1125
|
-
if (typeof fallback === "string" && fallback.length > 0) {
|
|
1126
|
-
console.log("[WWW] render/_locale:resolveLocale ->", fallback, "(from config.localization.defaultLocale)");
|
|
1127
|
-
return fallback;
|
|
1128
|
-
}
|
|
1129
|
-
console.log('[WWW] render/_locale:resolveLocale -> "" (no locale anywhere)');
|
|
1130
|
-
return "";
|
|
1131
|
-
}
|
|
1132
|
-
function allLocales(req) {
|
|
1133
|
-
if (!req || typeof req !== "object") {
|
|
1134
|
-
console.log("[WWW] render/_locale:allLocales -> [] (no req)");
|
|
1135
|
-
return [];
|
|
1136
|
-
}
|
|
1137
|
-
const r = req;
|
|
1138
|
-
const list = r.payload?.config?.localization?.locales;
|
|
1139
|
-
if (!Array.isArray(list) || list.length === 0) {
|
|
1140
|
-
console.log("[WWW] render/_locale:allLocales -> [] (no locales declared)");
|
|
1141
|
-
return [];
|
|
1142
|
-
}
|
|
1143
|
-
const out = [];
|
|
1144
|
-
for (const entry of list) {
|
|
1145
|
-
if (typeof entry === "string" && entry.length > 0) {
|
|
1146
|
-
out.push(entry);
|
|
1147
|
-
} else if (entry && typeof entry === "object" && "code" in entry) {
|
|
1148
|
-
const code = entry.code;
|
|
1149
|
-
if (typeof code === "string" && code.length > 0)
|
|
1150
|
-
out.push(code);
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
console.log("[WWW] render/_locale:allLocales ->", JSON.stringify(out));
|
|
1154
|
-
return out;
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
// src/render/hooks/_shared.ts
|
|
1158
|
-
var cachePromise = null;
|
|
1159
|
-
function nextCacheImport() {
|
|
1160
|
-
return cachePromise ??= import("next/cache");
|
|
1161
|
-
}
|
|
1162
|
-
function shouldSkipRevalidate(context) {
|
|
1163
|
-
const skip = Boolean(context?.disableRevalidate);
|
|
1164
|
-
if (skip)
|
|
1165
|
-
console.log("[WWW] render/hooks:_shared:shouldSkipRevalidate -> skip");
|
|
1166
|
-
return skip;
|
|
1167
|
-
}
|
|
1168
|
-
async function safeRevalidatePath(payload, path) {
|
|
1169
|
-
console.log("[WWW] render/hooks:_shared:safeRevalidatePath path=", path);
|
|
1170
|
-
try {
|
|
1171
|
-
const { revalidatePath } = await nextCacheImport();
|
|
1172
|
-
revalidatePath(path);
|
|
1173
|
-
} catch (error) {
|
|
1174
|
-
console.error("[WWW] render/hooks:_shared:safeRevalidatePath failed path=", path, "err=", String(error));
|
|
1175
|
-
payload.logger.error(`revalidatePath("${path}") failed: ${String(error)}`);
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
async function safeRevalidateTag(payload, tag, profile = "max") {
|
|
1179
|
-
console.log("[WWW] render/hooks:_shared:safeRevalidateTag tag=", tag, "profile=", profile);
|
|
1180
|
-
try {
|
|
1181
|
-
const { revalidateTag } = await nextCacheImport();
|
|
1182
|
-
revalidateTag(tag, profile);
|
|
1183
|
-
} catch (error) {
|
|
1184
|
-
console.error("[WWW] render/hooks:_shared:safeRevalidateTag failed tag=", tag, "err=", String(error));
|
|
1185
|
-
payload.logger.error(`revalidateTag("${tag}") failed: ${String(error)}`);
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
// src/render/hooks/revalidateCollection.ts
|
|
1190
|
-
function createRevalidateCollectionHook(options) {
|
|
1191
|
-
const {
|
|
1192
|
-
collectionSlug,
|
|
1193
|
-
urlPathPrefix = "",
|
|
1194
|
-
sitemapTag,
|
|
1195
|
-
localePrefix: modeOption,
|
|
1196
|
-
defaultLocale: defaultLocaleOption,
|
|
1197
|
-
pathMode = "url"
|
|
1198
|
-
} = options;
|
|
1199
|
-
const resolvedSitemapTag = sitemapTag === false ? false : sitemapTag ?? `${collectionSlug}-sitemap`;
|
|
1200
|
-
console.log("[WWW] render/hooks:createRevalidateCollectionHook collectionSlug=", collectionSlug, "urlPathPrefix=", urlPathPrefix, "sitemapTag=", resolvedSitemapTag, "pathMode=", pathMode);
|
|
1201
|
-
const resolveDefaults = (req) => {
|
|
1202
|
-
const mode = modeOption ?? "always";
|
|
1203
|
-
const defaultLocale = defaultLocaleOption ?? req?.payload?.config?.localization?.defaultLocale ?? "";
|
|
1204
|
-
return { mode, defaultLocale };
|
|
1205
|
-
};
|
|
1206
|
-
const localesToFanOut = (req) => {
|
|
1207
|
-
const all = allLocales(req);
|
|
1208
|
-
if (all.length > 0)
|
|
1209
|
-
return all;
|
|
1210
|
-
const single = resolveLocale(req);
|
|
1211
|
-
return single ? [single] : [];
|
|
1212
|
-
};
|
|
1213
|
-
const collectionPath = (slug, locale, mode, defaultLocale) => {
|
|
1214
|
-
const prefix = prefixFor(locale, defaultLocale, mode);
|
|
1215
|
-
if (!slug)
|
|
1216
|
-
return `${prefix}${urlPathPrefix}` || "/";
|
|
1217
|
-
return `${prefix}${urlPathPrefix}/${slug}`;
|
|
1218
|
-
};
|
|
1219
|
-
const fanOutPaths = async (payload, req, slug, label) => {
|
|
1220
|
-
const { mode, defaultLocale } = resolveDefaults(req);
|
|
1221
|
-
const locales = localesToFanOut(req);
|
|
1222
|
-
for (const locale of locales) {
|
|
1223
|
-
const path = collectionPath(slug, locale, mode, defaultLocale);
|
|
1224
|
-
payload.logger.info?.(`${label} ${path}`);
|
|
1225
|
-
await safeRevalidatePath(payload, path);
|
|
1226
|
-
}
|
|
1227
|
-
};
|
|
1228
|
-
const fireCollectionTags = async (payload, docId, req) => {
|
|
1229
|
-
console.log("[WWW] render/hooks:fireCollectionTags collectionSlug=", collectionSlug, "docId=", docId);
|
|
1230
|
-
if (typeof docId === "string" || typeof docId === "number") {
|
|
1231
|
-
await safeRevalidateTag(payload, `collection_${collectionSlug}_${docId}`);
|
|
1232
|
-
}
|
|
1233
|
-
if (resolvedSitemapTag !== false) {
|
|
1234
|
-
await safeRevalidateTag(payload, resolvedSitemapTag);
|
|
1235
|
-
}
|
|
1236
|
-
};
|
|
1237
|
-
const afterChange = async ({ doc, previousDoc, req }) => {
|
|
1238
|
-
if (shouldSkipRevalidate(req.context))
|
|
1239
|
-
return doc;
|
|
1240
|
-
const { payload } = req;
|
|
1241
|
-
const typed = doc;
|
|
1242
|
-
const prev = previousDoc;
|
|
1243
|
-
console.log("[WWW] render/hooks:afterChange collectionSlug=", collectionSlug, "id=", typed.id, "slug=", typed.slug, "prevSlug=", prev?.slug);
|
|
1244
|
-
const isPublished = typed._status === "published";
|
|
1245
|
-
const wasPublished = prev?._status === "published";
|
|
1246
|
-
const prevSlugIsString = typeof prev?.slug === "string";
|
|
1247
|
-
const slugChanged = prevSlugIsString && prev?.slug !== typed.slug;
|
|
1248
|
-
if (isPublished) {
|
|
1249
|
-
if (pathMode !== "tag-only") {
|
|
1250
|
-
await fanOutPaths(payload, req, typed.slug, `Revalidating ${collectionSlug} at path:`);
|
|
1251
|
-
}
|
|
1252
|
-
await fireCollectionTags(payload, typed.id, req);
|
|
1253
|
-
}
|
|
1254
|
-
if (wasPublished && (!isPublished || slugChanged)) {
|
|
1255
|
-
if (pathMode !== "tag-only") {
|
|
1256
|
-
await fanOutPaths(payload, req, prev?.slug, `Revalidating old ${collectionSlug} at path:`);
|
|
1257
|
-
}
|
|
1258
|
-
await fireCollectionTags(payload, typed.id, req);
|
|
1259
|
-
}
|
|
1260
|
-
return doc;
|
|
1261
|
-
};
|
|
1262
|
-
const afterDelete = async ({ doc, req }) => {
|
|
1263
|
-
if (shouldSkipRevalidate(req.context))
|
|
1264
|
-
return doc ?? null;
|
|
1265
|
-
const { payload } = req;
|
|
1266
|
-
const typed = doc;
|
|
1267
|
-
console.log("[WWW] render/hooks:afterDelete collectionSlug=", collectionSlug, "id=", typed?.id, "slug=", typed?.slug);
|
|
1268
|
-
if (pathMode !== "tag-only") {
|
|
1269
|
-
await fanOutPaths(payload, req, typed?.slug, `Revalidating deleted ${collectionSlug} at path:`);
|
|
1270
|
-
}
|
|
1271
|
-
await fireCollectionTags(payload, typed?.id, req);
|
|
1272
|
-
return doc ?? null;
|
|
1273
|
-
};
|
|
1274
|
-
return { afterChange, afterDelete };
|
|
1275
|
-
}
|
|
1276
|
-
var createRevalidatePageHooks = (opts = {}) => {
|
|
1277
|
-
console.log("[WWW] render/hooks:createRevalidatePageHooks (deprecated alias) opts=", JSON.stringify(opts));
|
|
1278
|
-
return createRevalidateCollectionHook({
|
|
1279
|
-
collectionSlug: "pages",
|
|
1280
|
-
urlPathPrefix: "",
|
|
1281
|
-
...opts
|
|
1282
|
-
});
|
|
1283
|
-
};
|
|
1284
|
-
|
|
1285
|
-
// src/data/collections/StaticPages/index.ts
|
|
1286
|
-
var createStaticPagesCollection = (blocks) => {
|
|
1287
|
-
const { afterChange, afterDelete } = createRevalidateCollectionHook({
|
|
1288
|
-
collectionSlug: STATIC_PAGES_SLUG,
|
|
1289
|
-
pathMode: "tag-only",
|
|
1290
|
-
sitemapTag: "static-pages"
|
|
1291
|
-
});
|
|
1292
|
-
return {
|
|
1293
|
-
slug: STATIC_PAGES_SLUG,
|
|
1294
|
-
dbName: "sp",
|
|
1295
|
-
admin: { group: "System", useAsTitle: "title" },
|
|
1296
|
-
access: {
|
|
1297
|
-
create: authenticated,
|
|
1298
|
-
delete: authenticated,
|
|
1299
|
-
read: authenticatedOrPublished,
|
|
1300
|
-
update: authenticated
|
|
1301
|
-
},
|
|
1302
|
-
fields: [
|
|
1303
|
-
{
|
|
1304
|
-
name: "kind",
|
|
1305
|
-
type: "select",
|
|
1306
|
-
required: true,
|
|
1307
|
-
unique: true,
|
|
1308
|
-
index: true,
|
|
1309
|
-
options: [
|
|
1310
|
-
{ label: "Not found (404)", value: "not-found" },
|
|
1311
|
-
{ label: "Server error (500)", value: "server-error" },
|
|
1312
|
-
{ label: "Search empty", value: "search-empty" },
|
|
1313
|
-
{ label: "Offline", value: "offline" }
|
|
1314
|
-
],
|
|
1315
|
-
admin: {
|
|
1316
|
-
position: "sidebar",
|
|
1317
|
-
description: "Which system page this row powers. One row per kind."
|
|
1318
|
-
}
|
|
1319
|
-
},
|
|
1320
|
-
{
|
|
1321
|
-
name: "title",
|
|
1322
|
-
type: "text",
|
|
1323
|
-
required: true,
|
|
1324
|
-
localized: true,
|
|
1325
|
-
admin: { description: "Admin-only label. Not rendered." }
|
|
1326
|
-
},
|
|
1327
|
-
{
|
|
1328
|
-
type: "tabs",
|
|
1329
|
-
tabs: [
|
|
1330
|
-
{
|
|
1331
|
-
fields: [
|
|
1332
|
-
{
|
|
1333
|
-
name: "blocks",
|
|
1334
|
-
type: "blocks",
|
|
1335
|
-
localized: true,
|
|
1336
|
-
blocks,
|
|
1337
|
-
admin: { initCollapsed: true },
|
|
1338
|
-
dbName: "b"
|
|
1339
|
-
}
|
|
1340
|
-
],
|
|
1341
|
-
label: "Content"
|
|
1342
|
-
}
|
|
1343
|
-
]
|
|
1344
|
-
},
|
|
1345
|
-
{
|
|
1346
|
-
name: "publishedAt",
|
|
1347
|
-
type: "date",
|
|
1348
|
-
admin: { position: "sidebar" }
|
|
1349
|
-
}
|
|
1350
|
-
],
|
|
1351
|
-
hooks: {
|
|
1352
|
-
afterChange: [afterChange],
|
|
1353
|
-
afterDelete: [afterDelete]
|
|
1354
|
-
},
|
|
1355
|
-
versions: { drafts: { autosave: { interval: 1000 } } }
|
|
1356
|
-
};
|
|
1357
|
-
};
|
|
1358
|
-
|
|
1359
|
-
// src/render/pages/createStaticPageExports.tsx
|
|
1360
|
-
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1361
|
-
function createStaticPageExports({
|
|
1362
|
-
kind = "not-found",
|
|
1363
|
-
config: configPromise,
|
|
1364
|
-
importMap: importMapArg
|
|
1365
|
-
}) {
|
|
1366
|
-
const importMap = importMapArg ?? {};
|
|
1367
|
-
let dbgRenderCount = 0;
|
|
1368
|
-
const default_ = async () => {
|
|
1369
|
-
const { getLocale } = await import("next-intl/server");
|
|
1370
|
-
const locale = await getLocale();
|
|
1371
|
-
console.log("[WWW] render/pages:createStaticPageExports:default_ kind=", kind, "locale=", locale);
|
|
1372
|
-
dbgRenderCount++;
|
|
1373
|
-
{
|
|
1374
|
-
let reqUrl = "?";
|
|
1375
|
-
try {
|
|
1376
|
-
const { headers } = await import("next/headers");
|
|
1377
|
-
const h = await headers();
|
|
1378
|
-
reqUrl = h.get("x-invoke-path") || h.get("x-matched-path") || h.get("x-next-url") || h.get("next-url") || h.get("referer") || "?";
|
|
1379
|
-
} catch {}
|
|
1380
|
-
console.error(`[WWW-DBG static-render #${dbgRenderCount}] kind=${kind} locale=${locale} url=${reqUrl}`);
|
|
1381
|
-
if (dbgRenderCount <= 5) {
|
|
1382
|
-
console.error(`[WWW-DBG static-render #${dbgRenderCount}] stack:
|
|
1383
|
-
` + (new Error("static-render").stack?.split(`
|
|
1384
|
-
`).slice(2, 12).join(`
|
|
1385
|
-
`) ?? ""));
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
const doc = await queryDocBySlug({
|
|
1389
|
-
collectionSlug: STATIC_PAGES_SLUG,
|
|
1390
|
-
slug: kind,
|
|
1391
|
-
slugField: "kind",
|
|
1392
|
-
locale,
|
|
1393
|
-
config: configPromise
|
|
1394
|
-
});
|
|
1395
|
-
if (!doc) {
|
|
1396
|
-
console.warn("[createStaticPageExports] !doc: STATIC_PAGES_SLUG=", STATIC_PAGES_SLUG, "slug:" + kind);
|
|
1397
|
-
return /* @__PURE__ */ jsx9("section", {
|
|
1398
|
-
children: /* @__PURE__ */ jsx9("h1", {
|
|
1399
|
-
children: "404"
|
|
1400
|
-
})
|
|
1401
|
-
});
|
|
1402
|
-
}
|
|
1403
|
-
const cfg = await configPromise;
|
|
1404
|
-
console.log("[WWW] render/pages:createStaticPageExports:default_ -> rendering via PagesPage kind=", kind, "locale=", locale);
|
|
1405
|
-
return /* @__PURE__ */ jsx9(PagesPage, {
|
|
1406
|
-
doc,
|
|
1407
|
-
locale,
|
|
1408
|
-
importMap,
|
|
1409
|
-
config: cfg
|
|
1410
|
-
});
|
|
1411
|
-
};
|
|
1412
|
-
return { default: default_ };
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
587
|
// src/exports/render-pages.ts
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
import { RichText as RichText2 } from "@payloadcms/richtext-lexical/react";
|
|
1420
|
-
import { jsx as jsx10, jsxs as jsxs5, Fragment as Fragment6 } from "react/jsx-runtime";
|
|
1421
|
-
async function PostsPage({ doc, locale, importMap: _importMap }) {
|
|
1422
|
-
if (!doc) {
|
|
1423
|
-
console.log("[WWW] render/pages:PostsPage no doc");
|
|
1424
|
-
return /* @__PURE__ */ jsx10(Fragment6, {});
|
|
1425
|
-
}
|
|
1426
|
-
const title = readText(doc.title, locale);
|
|
1427
|
-
const excerpt = readText(doc.excerpt, locale);
|
|
1428
|
-
const content = doc.content;
|
|
1429
|
-
console.log("[WWW] render/pages:PostsPage titleLen=", title.length, "excerptLen=", excerpt.length, "hasContent=", Boolean(content), "locale=", locale);
|
|
1430
|
-
return /* @__PURE__ */ jsxs5("article", {
|
|
1431
|
-
className: "posts-page prose prose-neutral dark:prose-invert mx-auto max-w-3xl py-10",
|
|
1432
|
-
children: [
|
|
1433
|
-
/* @__PURE__ */ jsxs5("header", {
|
|
1434
|
-
className: "posts-page__header not-prose mb-8",
|
|
1435
|
-
children: [
|
|
1436
|
-
/* @__PURE__ */ jsx10("h1", {
|
|
1437
|
-
className: "posts-page__title text-4xl font-semibold tracking-tight",
|
|
1438
|
-
children: title
|
|
1439
|
-
}),
|
|
1440
|
-
excerpt ? /* @__PURE__ */ jsx10("p", {
|
|
1441
|
-
className: "posts-page__excerpt mt-3 text-lg text-muted-foreground",
|
|
1442
|
-
children: excerpt
|
|
1443
|
-
}) : null
|
|
1444
|
-
]
|
|
1445
|
-
}),
|
|
1446
|
-
content ? /* @__PURE__ */ jsx10("div", {
|
|
1447
|
-
className: "posts-page__content",
|
|
1448
|
-
children: /* @__PURE__ */ jsx10(RichText2, {
|
|
1449
|
-
data: content
|
|
1450
|
-
})
|
|
1451
|
-
}) : null
|
|
1452
|
-
]
|
|
1453
|
-
});
|
|
1454
|
-
}
|
|
1455
|
-
function readText(value, preferredLocale) {
|
|
1456
|
-
if (typeof value !== "string")
|
|
1457
|
-
return "";
|
|
1458
|
-
if (!value.startsWith("{"))
|
|
1459
|
-
return value;
|
|
1460
|
-
try {
|
|
1461
|
-
const parsed = JSON.parse(value);
|
|
1462
|
-
if (typeof parsed === "string")
|
|
1463
|
-
return parsed;
|
|
1464
|
-
if (parsed && typeof parsed === "object") {
|
|
1465
|
-
const obj = parsed;
|
|
1466
|
-
if (preferredLocale && typeof obj[preferredLocale] === "string" && obj[preferredLocale].length > 0) {
|
|
1467
|
-
return obj[preferredLocale];
|
|
1468
|
-
}
|
|
1469
|
-
const first = Object.values(obj).find((v) => typeof v === "string" && v.length > 0);
|
|
1470
|
-
return typeof first === "string" ? first : value;
|
|
1471
|
-
}
|
|
1472
|
-
return value;
|
|
1473
|
-
} catch {
|
|
1474
|
-
return value;
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
// src/render/pages/HeaderPage.tsx
|
|
1479
|
-
import"server-only";
|
|
1480
|
-
import { jsx as jsx11, jsxs as jsxs6, Fragment as Fragment7 } from "react/jsx-runtime";
|
|
1481
|
-
function HeaderPage({ data, locale: _locale }) {
|
|
1482
|
-
if (!data) {
|
|
1483
|
-
console.log("[WWW] render/pages:HeaderPage no data");
|
|
1484
|
-
return /* @__PURE__ */ jsx11(Fragment7, {});
|
|
1485
|
-
}
|
|
1486
|
-
const nav = data.nav ?? [];
|
|
1487
|
-
const items = nav.filter((b) => b.blockType === "navItem");
|
|
1488
|
-
const columns = nav.filter((b) => b.blockType === "navColumn");
|
|
1489
|
-
console.log("[WWW] render/pages:HeaderPage items=", items.length, "columns=", columns.length, "locale=", _locale);
|
|
1490
|
-
const renderLink = (link, fallbackHref = "#") => {
|
|
1491
|
-
if (!link)
|
|
1492
|
-
return /* @__PURE__ */ jsx11("a", {
|
|
1493
|
-
href: fallbackHref,
|
|
1494
|
-
children: link?.label ?? ""
|
|
1495
|
-
});
|
|
1496
|
-
if (link.type === "custom" && typeof link.url === "string") {
|
|
1497
|
-
return /* @__PURE__ */ jsx11("a", {
|
|
1498
|
-
href: link.url,
|
|
1499
|
-
children: link.label
|
|
1500
|
-
});
|
|
1501
|
-
}
|
|
1502
|
-
if (link.type === "reference" && link.reference) {
|
|
1503
|
-
const ref = link.reference;
|
|
1504
|
-
if (typeof ref === "object" && ref.slug) {
|
|
1505
|
-
return /* @__PURE__ */ jsx11("a", {
|
|
1506
|
-
href: `/${ref.slug}`,
|
|
1507
|
-
children: link.label
|
|
1508
|
-
});
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
return /* @__PURE__ */ jsx11("a", {
|
|
1512
|
-
href: fallbackHref,
|
|
1513
|
-
children: link.label ?? ""
|
|
1514
|
-
});
|
|
1515
|
-
};
|
|
1516
|
-
return /* @__PURE__ */ jsxs6("nav", {
|
|
1517
|
-
children: [
|
|
1518
|
-
items.map((item, i) => /* @__PURE__ */ jsx11("span", {
|
|
1519
|
-
style: { marginRight: 16 },
|
|
1520
|
-
children: renderLink(item.link)
|
|
1521
|
-
}, `item-${i}`)),
|
|
1522
|
-
columns.map((col, i) => /* @__PURE__ */ jsxs6("div", {
|
|
1523
|
-
style: { display: "inline-block", marginRight: 24, verticalAlign: "top" },
|
|
1524
|
-
children: [
|
|
1525
|
-
col.title ? /* @__PURE__ */ jsx11("strong", {
|
|
1526
|
-
children: col.title
|
|
1527
|
-
}) : null,
|
|
1528
|
-
/* @__PURE__ */ jsx11("div", {
|
|
1529
|
-
children: (col.links ?? []).map((entry, j) => /* @__PURE__ */ jsx11("div", {
|
|
1530
|
-
children: renderLink(entry.link)
|
|
1531
|
-
}, `col-${i}-link-${j}`))
|
|
1532
|
-
})
|
|
1533
|
-
]
|
|
1534
|
-
}, `col-${i}`))
|
|
1535
|
-
]
|
|
1536
|
-
});
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
// src/render/pages/FooterPage.tsx
|
|
1540
|
-
import"server-only";
|
|
1541
|
-
import { jsx as jsx12, jsxs as jsxs7, Fragment as Fragment8 } from "react/jsx-runtime";
|
|
1542
|
-
function FooterPage({ data, locale: _locale }) {
|
|
1543
|
-
if (!data) {
|
|
1544
|
-
console.log("[WWW] render/pages:FooterPage no data");
|
|
1545
|
-
return /* @__PURE__ */ jsx12(Fragment8, {});
|
|
1546
|
-
}
|
|
1547
|
-
const nav = data.nav ?? [];
|
|
1548
|
-
const items = nav.filter((b) => b.blockType === "navItem");
|
|
1549
|
-
const columns = nav.filter((b) => b.blockType === "navColumn");
|
|
1550
|
-
console.log("[WWW] render/pages:FooterPage items=", items.length, "columns=", columns.length, "locale=", _locale);
|
|
1551
|
-
const renderLink = (link, fallbackHref = "#") => {
|
|
1552
|
-
if (!link)
|
|
1553
|
-
return /* @__PURE__ */ jsx12("a", {
|
|
1554
|
-
href: fallbackHref,
|
|
1555
|
-
children: link?.label ?? ""
|
|
1556
|
-
});
|
|
1557
|
-
if (link.type === "custom" && typeof link.url === "string") {
|
|
1558
|
-
return /* @__PURE__ */ jsx12("a", {
|
|
1559
|
-
href: link.url,
|
|
1560
|
-
children: link.label
|
|
1561
|
-
});
|
|
1562
|
-
}
|
|
1563
|
-
if (link.type === "reference" && link.reference) {
|
|
1564
|
-
const ref = link.reference;
|
|
1565
|
-
if (typeof ref === "object" && ref.slug) {
|
|
1566
|
-
return /* @__PURE__ */ jsx12("a", {
|
|
1567
|
-
href: `/${ref.slug}`,
|
|
1568
|
-
children: link.label
|
|
1569
|
-
});
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
return /* @__PURE__ */ jsx12("a", {
|
|
1573
|
-
href: fallbackHref,
|
|
1574
|
-
children: link.label ?? ""
|
|
1575
|
-
});
|
|
1576
|
-
};
|
|
1577
|
-
return /* @__PURE__ */ jsx12("footer", {
|
|
1578
|
-
children: /* @__PURE__ */ jsxs7("div", {
|
|
1579
|
-
children: [
|
|
1580
|
-
items.map((item, i) => /* @__PURE__ */ jsx12("span", {
|
|
1581
|
-
style: { marginRight: 16 },
|
|
1582
|
-
children: renderLink(item.link)
|
|
1583
|
-
}, `item-${i}`)),
|
|
1584
|
-
columns.map((col, i) => /* @__PURE__ */ jsxs7("div", {
|
|
1585
|
-
style: { display: "inline-block", marginRight: 24, verticalAlign: "top" },
|
|
1586
|
-
children: [
|
|
1587
|
-
col.title ? /* @__PURE__ */ jsx12("strong", {
|
|
1588
|
-
children: col.title
|
|
1589
|
-
}) : null,
|
|
1590
|
-
/* @__PURE__ */ jsx12("div", {
|
|
1591
|
-
children: (col.links ?? []).map((entry, j) => /* @__PURE__ */ jsx12("div", {
|
|
1592
|
-
children: renderLink(entry.link)
|
|
1593
|
-
}, `col-${i}-link-${j}`))
|
|
1594
|
-
})
|
|
1595
|
-
]
|
|
1596
|
-
}, `col-${i}`))
|
|
1597
|
-
]
|
|
1598
|
-
})
|
|
1599
|
-
});
|
|
1600
|
-
}
|
|
1601
|
-
|
|
1602
|
-
// src/exports/render-pages.ts
|
|
1603
|
-
var PageShowcase2 = PageShowcase;
|
|
1604
|
-
var render_pages_default = {
|
|
1605
|
-
addCollectionsToSitemap,
|
|
1606
|
-
createCollectionPageExports,
|
|
1607
|
-
createRootLayoutExports,
|
|
1608
|
-
createStaticPageExports,
|
|
1609
|
-
HeaderPage,
|
|
1610
|
-
FooterPage,
|
|
1611
|
-
PagesPage,
|
|
1612
|
-
PostsPage,
|
|
1613
|
-
PageShowcase: PageShowcase2
|
|
1614
|
-
};
|
|
588
|
+
import { RootJsonLd as RootJsonLd2 } from "@justanarthur/payload-plugin-seo/root-jsonld";
|
|
589
|
+
var renderPages = { createCollectionPageExports, createRootLayoutExports, PagesPage, PostsPage, HeaderPage, FooterPage, RootJsonLd: RootJsonLd2 };
|
|
590
|
+
var render_pages_default = renderPages;
|
|
1615
591
|
export {
|
|
1616
592
|
render_pages_default as default,
|
|
1617
|
-
createStaticPageExports,
|
|
1618
593
|
createRootLayoutExports,
|
|
1619
594
|
createCollectionPageExports,
|
|
1620
|
-
|
|
595
|
+
RootJsonLd2 as RootJsonLd,
|
|
1621
596
|
PostsPage,
|
|
1622
597
|
PagesPage,
|
|
1623
|
-
PageShowcase2 as PageShowcase,
|
|
1624
598
|
HeaderPage,
|
|
1625
599
|
FooterPage
|
|
1626
600
|
};
|