@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/pages.js
CHANGED
|
@@ -1,294 +1,20 @@
|
|
|
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 jsx6, jsxs as jsxs3 } 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__ */ jsxs3("div", {
|
|
57
|
-
className: "page-showcase grid gap-8 lg:grid-cols-[1fr_320px]",
|
|
58
|
-
children: [
|
|
59
|
-
/* @__PURE__ */ jsx6("main", {
|
|
60
|
-
className: "page-showcase__main",
|
|
61
|
-
children
|
|
62
|
-
}),
|
|
63
|
-
/* @__PURE__ */ jsxs3("aside", {
|
|
64
|
-
className: "page-showcase__sidebar flex flex-col gap-6 text-sm",
|
|
65
|
-
children: [
|
|
66
|
-
/* @__PURE__ */ jsxs3("section", {
|
|
67
|
-
className: "page-showcase__locale",
|
|
68
|
-
children: [
|
|
69
|
-
/* @__PURE__ */ jsx6("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__ */ jsxs3("section", {
|
|
77
|
-
className: "page-showcase__metadata",
|
|
78
|
-
children: [
|
|
79
|
-
/* @__PURE__ */ jsx6("h2", {
|
|
80
|
-
className: "m-0 mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",
|
|
81
|
-
children: metadataHeading
|
|
82
|
-
}),
|
|
83
|
-
/* @__PURE__ */ jsx6("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__ */ jsxs3(React.Fragment, {
|
|
86
|
-
children: [
|
|
87
|
-
/* @__PURE__ */ jsx6("dt", {
|
|
88
|
-
className: "font-medium text-muted-foreground",
|
|
89
|
-
children: label
|
|
90
|
-
}),
|
|
91
|
-
/* @__PURE__ */ jsx6("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__ */ jsxs3("section", {
|
|
101
|
-
className: "page-showcase__jsonld",
|
|
102
|
-
children: [
|
|
103
|
-
/* @__PURE__ */ jsx6("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__ */ jsxs3("details", {
|
|
108
|
-
className: "mb-2 rounded border border-border bg-muted/30 p-2",
|
|
109
|
-
children: [
|
|
110
|
-
/* @__PURE__ */ jsx6("summary", {
|
|
111
|
-
className: "cursor-pointer font-mono text-xs",
|
|
112
|
-
children: id
|
|
113
|
-
}),
|
|
114
|
-
/* @__PURE__ */ jsx6("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
|
-
|
|
139
|
-
// src/render/components/LocaleSwitcher.tsx
|
|
140
|
-
var exports_LocaleSwitcher = {};
|
|
141
|
-
__export(exports_LocaleSwitcher, {
|
|
142
|
-
LocaleSwitcher: () => LocaleSwitcher
|
|
143
|
-
});
|
|
144
|
-
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
145
|
-
function LocaleSwitcher({
|
|
146
|
-
currentLocale,
|
|
147
|
-
hreflangAlternates,
|
|
148
|
-
labels
|
|
149
|
-
}) {
|
|
150
|
-
const locales = Object.keys(hreflangAlternates).filter((k) => k !== "x-default");
|
|
151
|
-
console.log("[WWW] render/components:LocaleSwitcher currentLocale=", currentLocale, "locales=", JSON.stringify(locales), "hasXDefault=", Boolean(hreflangAlternates["x-default"]));
|
|
152
|
-
return /* @__PURE__ */ jsx7("nav", {
|
|
153
|
-
"aria-label": "Language",
|
|
154
|
-
className: "locale-switcher",
|
|
155
|
-
children: /* @__PURE__ */ jsxs4("ul", {
|
|
156
|
-
className: "flex flex-wrap gap-2 list-none p-0 m-0",
|
|
157
|
-
children: [
|
|
158
|
-
locales.map((locale) => {
|
|
159
|
-
const href = hreflangAlternates[locale];
|
|
160
|
-
if (!href)
|
|
161
|
-
return null;
|
|
162
|
-
const isCurrent = locale === currentLocale;
|
|
163
|
-
return /* @__PURE__ */ jsx7("li", {
|
|
164
|
-
children: /* @__PURE__ */ jsx7("a", {
|
|
165
|
-
href,
|
|
166
|
-
"aria-current": isCurrent ? "true" : undefined,
|
|
167
|
-
hrefLang: locale,
|
|
168
|
-
className: "locale-switcher__link",
|
|
169
|
-
"data-locale": locale,
|
|
170
|
-
children: labels?.[locale] ?? locale.toUpperCase()
|
|
171
|
-
})
|
|
172
|
-
}, locale);
|
|
173
|
-
}),
|
|
174
|
-
hreflangAlternates["x-default"] ? /* @__PURE__ */ jsx7("li", {
|
|
175
|
-
children: /* @__PURE__ */ jsx7("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
|
|
183
|
-
]
|
|
184
|
-
})
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
var init_LocaleSwitcher = () => {};
|
|
188
|
-
|
|
189
|
-
// src/core/utils/getFromImportMap.ts
|
|
190
|
-
function getFromImportMap(key, importMap) {
|
|
191
|
-
const resolvedKey = key.includes("#") ? key : key + "#default";
|
|
192
|
-
const value = importMap[resolvedKey];
|
|
193
|
-
console.log("[WWW] core/utils:getFromImportMap key=", key, "resolved=", resolvedKey, "hit=", Boolean(value));
|
|
194
|
-
return value;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// src/core/utils/generateImportName.ts
|
|
198
|
-
function generateImportName(type, slug) {
|
|
199
|
-
switch (type) {
|
|
200
|
-
case "block": {
|
|
201
|
-
const name = `Block${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
202
|
-
console.log("[WWW] core/utils:generateImportName type=block slug=", slug, "->", name);
|
|
203
|
-
return name;
|
|
204
|
-
}
|
|
205
|
-
case "page": {
|
|
206
|
-
const name = `Page${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
207
|
-
console.log("[WWW] core/utils:generateImportName type=page slug=", slug, "->", name);
|
|
208
|
-
return name;
|
|
209
|
-
}
|
|
210
|
-
default:
|
|
211
|
-
console.error("[WWW] core/utils:generateImportName unknown type:", type);
|
|
212
|
-
throw new Error(`Unknown type: ${type}`);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
2
|
|
|
216
|
-
// src/render/
|
|
217
|
-
import { jsx, Fragment } from "react/jsx-runtime";
|
|
218
|
-
var RenderBlocks = ({
|
|
219
|
-
blocks,
|
|
220
|
-
blockProps,
|
|
221
|
-
config,
|
|
222
|
-
importMap,
|
|
223
|
-
locale,
|
|
224
|
-
searchParams
|
|
225
|
-
}) => {
|
|
226
|
-
if (!blocks || !Array.isArray(blocks) || blocks.length === 0) {
|
|
227
|
-
console.log("[WWW] render/blocks:RenderBlocks no blocks (locale=", locale, ")");
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
console.log("[WWW] render/blocks:RenderBlocks rendering count=", blocks.length, "locale=", locale);
|
|
231
|
-
const rendered = [];
|
|
232
|
-
for (let i = 0;i < blocks.length; i++) {
|
|
233
|
-
const block = blocks[i];
|
|
234
|
-
const { blockType } = block;
|
|
235
|
-
const importMapPath = config.admin?.dependencies?.[blockType]?.path ?? generateImportName("block", blockType);
|
|
236
|
-
const Block = getFromImportMap(importMapPath, importMap);
|
|
237
|
-
if (!Block) {
|
|
238
|
-
console.warn(`[WWW] render/blocks:RenderBlocks no block for type=${blockType} importMapPath=${importMapPath} (locale=${locale})`);
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
console.log("[WWW] render/blocks:RenderBlocks [", i, "] blockType=", blockType, "importMapPath=", importMapPath);
|
|
242
|
-
rendered.push(/* @__PURE__ */ jsx(Block, {
|
|
243
|
-
index: i,
|
|
244
|
-
...blockProps,
|
|
245
|
-
...block,
|
|
246
|
-
locale,
|
|
247
|
-
searchParams
|
|
248
|
-
}, i));
|
|
249
|
-
}
|
|
250
|
-
return /* @__PURE__ */ jsx(Fragment, {
|
|
251
|
-
children: rendered
|
|
252
|
-
});
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
// src/render/pages/PagesPage.tsx
|
|
256
|
-
import { jsx as jsx2, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
257
|
-
async function PagesPage({ doc, ...props }) {
|
|
258
|
-
if (!doc) {
|
|
259
|
-
console.log("[WWW] render/pages:PagesPage no doc");
|
|
260
|
-
return /* @__PURE__ */ jsx2(Fragment2, {});
|
|
261
|
-
}
|
|
262
|
-
const blocks = doc.blocks ?? [];
|
|
263
|
-
console.log("[WWW] render/pages:PagesPage blocks=", blocks.length, "locale=", props.locale);
|
|
264
|
-
return /* @__PURE__ */ jsx2(Fragment2, {
|
|
265
|
-
children: /* @__PURE__ */ jsx2(RenderBlocks, {
|
|
266
|
-
blocks,
|
|
267
|
-
...props
|
|
268
|
-
})
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// src/render/pages/HeaderPage.tsx
|
|
3
|
+
// src/render/pages/FooterPage.tsx
|
|
273
4
|
import"server-only";
|
|
274
|
-
import { jsx
|
|
275
|
-
function
|
|
276
|
-
if (!data) {
|
|
277
|
-
console.log("[WWW] render/pages:HeaderPage no data");
|
|
278
|
-
return /* @__PURE__ */ jsx3(Fragment3, {});
|
|
279
|
-
}
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
function FooterPage({ data }) {
|
|
280
7
|
const nav = data.nav ?? [];
|
|
281
8
|
const items = nav.filter((b) => b.blockType === "navItem");
|
|
282
9
|
const columns = nav.filter((b) => b.blockType === "navColumn");
|
|
283
|
-
console.log("[WWW] render/pages:HeaderPage items=", items.length, "columns=", columns.length, "locale=", _locale);
|
|
284
10
|
const renderLink = (link, fallbackHref = "#") => {
|
|
285
11
|
if (!link)
|
|
286
|
-
return /* @__PURE__ */
|
|
12
|
+
return /* @__PURE__ */ jsx("a", {
|
|
287
13
|
href: fallbackHref,
|
|
288
14
|
children: link?.label ?? ""
|
|
289
15
|
});
|
|
290
16
|
if (link.type === "custom" && typeof link.url === "string") {
|
|
291
|
-
return /* @__PURE__ */
|
|
17
|
+
return /* @__PURE__ */ jsx("a", {
|
|
292
18
|
href: link.url,
|
|
293
19
|
children: link.label
|
|
294
20
|
});
|
|
@@ -296,60 +22,57 @@ function HeaderPage({ data, locale: _locale }) {
|
|
|
296
22
|
if (link.type === "reference" && link.reference) {
|
|
297
23
|
const ref = link.reference;
|
|
298
24
|
if (typeof ref === "object" && ref.slug) {
|
|
299
|
-
return /* @__PURE__ */
|
|
25
|
+
return /* @__PURE__ */ jsx("a", {
|
|
300
26
|
href: `/${ref.slug}`,
|
|
301
27
|
children: link.label
|
|
302
28
|
});
|
|
303
29
|
}
|
|
304
30
|
}
|
|
305
|
-
return /* @__PURE__ */
|
|
31
|
+
return /* @__PURE__ */ jsx("a", {
|
|
306
32
|
href: fallbackHref,
|
|
307
33
|
children: link.label ?? ""
|
|
308
34
|
});
|
|
309
35
|
};
|
|
310
|
-
return /* @__PURE__ */
|
|
311
|
-
children:
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
children:
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
36
|
+
return /* @__PURE__ */ jsx("footer", {
|
|
37
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
38
|
+
children: [
|
|
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}`))
|
|
53
|
+
})
|
|
54
|
+
]
|
|
55
|
+
}, `col-${i}`))
|
|
56
|
+
]
|
|
57
|
+
})
|
|
330
58
|
});
|
|
331
59
|
}
|
|
332
60
|
|
|
333
|
-
// src/render/pages/
|
|
61
|
+
// src/render/pages/HeaderPage.tsx
|
|
334
62
|
import"server-only";
|
|
335
|
-
import { jsx as
|
|
336
|
-
function
|
|
337
|
-
if (!data) {
|
|
338
|
-
console.log("[WWW] render/pages:FooterPage no data");
|
|
339
|
-
return /* @__PURE__ */ jsx4(Fragment4, {});
|
|
340
|
-
}
|
|
63
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
64
|
+
function HeaderPage({ data }) {
|
|
341
65
|
const nav = data.nav ?? [];
|
|
342
66
|
const items = nav.filter((b) => b.blockType === "navItem");
|
|
343
67
|
const columns = nav.filter((b) => b.blockType === "navColumn");
|
|
344
|
-
console.log("[WWW] render/pages:FooterPage items=", items.length, "columns=", columns.length, "locale=", _locale);
|
|
345
68
|
const renderLink = (link, fallbackHref = "#") => {
|
|
346
69
|
if (!link)
|
|
347
|
-
return /* @__PURE__ */
|
|
70
|
+
return /* @__PURE__ */ jsx2("a", {
|
|
348
71
|
href: fallbackHref,
|
|
349
72
|
children: link?.label ?? ""
|
|
350
73
|
});
|
|
351
74
|
if (link.type === "custom" && typeof link.url === "string") {
|
|
352
|
-
return /* @__PURE__ */
|
|
75
|
+
return /* @__PURE__ */ jsx2("a", {
|
|
353
76
|
href: link.url,
|
|
354
77
|
children: link.label
|
|
355
78
|
});
|
|
@@ -357,284 +80,171 @@ function FooterPage({ data, locale: _locale }) {
|
|
|
357
80
|
if (link.type === "reference" && link.reference) {
|
|
358
81
|
const ref = link.reference;
|
|
359
82
|
if (typeof ref === "object" && ref.slug) {
|
|
360
|
-
return /* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ jsx2("a", {
|
|
361
84
|
href: `/${ref.slug}`,
|
|
362
85
|
children: link.label
|
|
363
86
|
});
|
|
364
87
|
}
|
|
365
88
|
}
|
|
366
|
-
return /* @__PURE__ */
|
|
89
|
+
return /* @__PURE__ */ jsx2("a", {
|
|
367
90
|
href: fallbackHref,
|
|
368
91
|
children: link.label ?? ""
|
|
369
92
|
});
|
|
370
93
|
};
|
|
371
|
-
return /* @__PURE__ */
|
|
372
|
-
children:
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
col.title
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
/* @__PURE__ */
|
|
385
|
-
children: (
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
]
|
|
392
|
-
})
|
|
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
|
+
]
|
|
393
114
|
});
|
|
394
115
|
}
|
|
395
116
|
|
|
396
|
-
// src/render/
|
|
397
|
-
|
|
398
|
-
|
|
117
|
+
// src/render/getFromImportMap.ts
|
|
118
|
+
function getFromImportMap(key, importMap) {
|
|
119
|
+
return key && importMap[key.includes("#") ? key : key + "#default"];
|
|
120
|
+
}
|
|
399
121
|
|
|
400
|
-
// src/
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
122
|
+
// src/render/generateImportName.ts
|
|
123
|
+
function generateImportName(type, slug) {
|
|
124
|
+
switch (type) {
|
|
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`;
|
|
129
|
+
default:
|
|
130
|
+
throw new Error(`Unknown type: ${type}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
409
133
|
|
|
410
|
-
// src/render/
|
|
411
|
-
import { jsx as
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
134
|
+
// src/render/blocks/renderBlocks.tsx
|
|
135
|
+
import { jsx as jsx3, Fragment } from "react/jsx-runtime";
|
|
136
|
+
var RenderBlocks = ({
|
|
137
|
+
blocks,
|
|
138
|
+
blockProps,
|
|
139
|
+
config,
|
|
140
|
+
importMap,
|
|
141
|
+
locale,
|
|
142
|
+
searchParams
|
|
143
|
+
}) => {
|
|
144
|
+
if (!blocks || !Array.isArray(blocks) || blocks.length === 0) {
|
|
145
|
+
console.log("[WWW] render/blocks:RenderBlocks no blocks (locale=", locale, ")");
|
|
416
146
|
return null;
|
|
417
147
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
148
|
+
console.log("[WWW] render/blocks:RenderBlocks rendering count=", blocks.length, "locale=", locale);
|
|
149
|
+
const rendered = [];
|
|
150
|
+
for (let i = 0;i < blocks.length; i++) {
|
|
151
|
+
const block = blocks[i];
|
|
152
|
+
const { blockType } = block;
|
|
153
|
+
const importMapPath = config.admin?.dependencies?.[blockType]?.path || generateImportName("block", blockType);
|
|
154
|
+
const Block = getFromImportMap(importMapPath, importMap);
|
|
155
|
+
if (!Block) {
|
|
156
|
+
console.warn(`[WWW] render/blocks:RenderBlocks no block for type=${blockType} importMapPath=${importMapPath} (locale=${locale})`);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
console.log("[WWW] render/blocks:RenderBlocks [", i, "] blockType=", blockType, "importMapPath=", importMapPath);
|
|
160
|
+
rendered.push(/* @__PURE__ */ jsx3(Block, {
|
|
161
|
+
index: i,
|
|
162
|
+
...blockProps,
|
|
163
|
+
...block,
|
|
164
|
+
locale,
|
|
165
|
+
searchParams
|
|
166
|
+
}, i));
|
|
423
167
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
168
|
+
return /* @__PURE__ */ jsx3(Fragment, {
|
|
169
|
+
children: rendered
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// src/render/pages/PagesPage.tsx
|
|
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,
|
|
427
180
|
...props
|
|
428
181
|
});
|
|
429
182
|
}
|
|
430
183
|
|
|
431
|
-
// src/render/
|
|
432
|
-
|
|
433
|
-
siteUrl,
|
|
434
|
-
locale,
|
|
435
|
-
urlPrefix,
|
|
436
|
-
storedSlug,
|
|
437
|
-
queryAllLocaleSlugs,
|
|
438
|
-
nested,
|
|
439
|
-
homeSlug,
|
|
440
|
-
defaultLocale,
|
|
441
|
-
locales,
|
|
442
|
-
localePrefix = "always"
|
|
443
|
-
}) {
|
|
444
|
-
const allLocaleSlugs = await queryAllLocaleSlugs(storedSlug, locale);
|
|
445
|
-
console.log("[WWW] render/metadata:buildHreflangAlternates storedSlug=", storedSlug, "locale=", locale, "allLocaleSlugs=", JSON.stringify(allLocaleSlugs));
|
|
446
|
-
const languages = {};
|
|
447
|
-
const urlFor = (l, slug) => {
|
|
448
|
-
const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
|
|
449
|
-
const prefixSegment = trimmedPrefix ? `/${trimmedPrefix}` : "";
|
|
450
|
-
const urlPath = slug === homeSlug ? "/" : nested ? "/" + slug.replaceAll("_", "/") : "/" + slug;
|
|
451
|
-
const localeSegment = localePrefix === "never" ? "" : localePrefix === "as-needed" && l === defaultLocale ? "" : `/${l}`;
|
|
452
|
-
return `${siteUrl}${localeSegment}${prefixSegment}${urlPath}`;
|
|
453
|
-
};
|
|
454
|
-
for (const l of locales) {
|
|
455
|
-
const slugForLocale = allLocaleSlugs?.[l];
|
|
456
|
-
if (!slugForLocale)
|
|
457
|
-
continue;
|
|
458
|
-
languages[l] = urlFor(l, slugForLocale);
|
|
459
|
-
}
|
|
460
|
-
if (allLocaleSlugs?.[defaultLocale]) {
|
|
461
|
-
languages["x-default"] = urlFor(defaultLocale, allLocaleSlugs[defaultLocale]);
|
|
462
|
-
}
|
|
463
|
-
console.log("[WWW] render/metadata:buildHreflangAlternates ->", JSON.stringify(languages));
|
|
464
|
-
return languages;
|
|
465
|
-
}
|
|
184
|
+
// src/render/pages/createCollectionPageExports.tsx
|
|
185
|
+
import"server-only";
|
|
466
186
|
|
|
467
|
-
// src/render/metadata/
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
if (!
|
|
471
|
-
return null;
|
|
472
|
-
if (typeof img === "string")
|
|
473
|
-
return img;
|
|
474
|
-
if (img?.url)
|
|
475
|
-
return img.url.startsWith("http") ? img.url : `${siteUrl}${img.url}`;
|
|
476
|
-
return null;
|
|
477
|
-
}
|
|
478
|
-
function getImageUrlWithLog(doc, siteUrl) {
|
|
479
|
-
const result = getImageUrl(doc, siteUrl);
|
|
480
|
-
console.log("[WWW] render/metadata:jsonld:getImageUrl ->", result);
|
|
481
|
-
return result;
|
|
482
|
-
}
|
|
483
|
-
function resolveLocalizedField(value, locale) {
|
|
484
|
-
if (value == null)
|
|
485
|
-
return "";
|
|
486
|
-
if (typeof value === "string") {
|
|
487
|
-
if (!value.startsWith("{"))
|
|
488
|
-
return value;
|
|
489
|
-
try {
|
|
490
|
-
const parsed = JSON.parse(value);
|
|
491
|
-
return resolveLocalizedField(parsed, locale);
|
|
492
|
-
} catch {
|
|
493
|
-
return value;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
if (typeof value !== "object")
|
|
187
|
+
// src/render/metadata/slug.ts
|
|
188
|
+
var SLUG_NESTED_DIVIDER = "_";
|
|
189
|
+
function paramsSlugToSlug(slug, _shape) {
|
|
190
|
+
if (!slug)
|
|
497
191
|
return "";
|
|
498
|
-
|
|
499
|
-
if (typeof obj[locale] === "string" && obj[locale].length > 0) {
|
|
500
|
-
return obj[locale];
|
|
501
|
-
}
|
|
502
|
-
return Object.values(obj).filter((v) => typeof v === "string" && v.length > 0).join(" / ");
|
|
503
|
-
}
|
|
504
|
-
function resolveLocalizedFieldWithLog(value, locale) {
|
|
505
|
-
const result = resolveLocalizedField(value, locale);
|
|
506
|
-
if (value && typeof value === "object") {
|
|
507
|
-
console.log("[WWW] render/metadata:jsonld:resolveLocalizedField locale=", locale, "->", JSON.stringify(result));
|
|
508
|
-
}
|
|
509
|
-
return result;
|
|
192
|
+
return (Array.isArray(slug) ? slug : [slug]).join(SLUG_NESTED_DIVIDER);
|
|
510
193
|
}
|
|
511
|
-
function
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
siteUrl,
|
|
516
|
-
type = "BlogPosting",
|
|
517
|
-
publisherName,
|
|
518
|
-
publisherLogo
|
|
519
|
-
}) {
|
|
520
|
-
const name = publisherName ?? new URL(siteUrl).hostname;
|
|
521
|
-
console.log("[WWW] render/metadata:buildArticleLd url=", url, "locale=", locale, "type=", type, "publisherName=", name);
|
|
522
|
-
const ld = {
|
|
523
|
-
"@context": "https://schema.org",
|
|
524
|
-
"@type": type,
|
|
525
|
-
"@id": `${url}#article`,
|
|
526
|
-
headline: resolveLocalizedFieldWithLog(doc.title, locale),
|
|
527
|
-
description: resolveLocalizedFieldWithLog(doc.meta?.description ?? doc.description ?? doc.excerpt, locale),
|
|
528
|
-
inLanguage: locale,
|
|
529
|
-
url,
|
|
530
|
-
dateModified: doc.updatedAt ? new Date(doc.updatedAt).toISOString() : undefined
|
|
531
|
-
};
|
|
532
|
-
const datePublished = doc.publishedAt ?? doc.createdAt;
|
|
533
|
-
if (datePublished)
|
|
534
|
-
ld.datePublished = new Date(datePublished).toISOString();
|
|
535
|
-
const imgUrl = getImageUrlWithLog(doc, siteUrl);
|
|
536
|
-
if (imgUrl)
|
|
537
|
-
ld.image = imgUrl;
|
|
538
|
-
ld.author = { "@type": "Organization", name, url: siteUrl };
|
|
539
|
-
const publisher = { "@type": "Organization", name };
|
|
540
|
-
if (publisherLogo !== undefined) {
|
|
541
|
-
if (publisherLogo !== null)
|
|
542
|
-
publisher.logo = { "@type": "ImageObject", url: publisherLogo };
|
|
543
|
-
}
|
|
544
|
-
ld.publisher = publisher;
|
|
545
|
-
return ld;
|
|
194
|
+
function slugToParamsSlug(slug, shape) {
|
|
195
|
+
if (!slug)
|
|
196
|
+
return shape === "catch-all" ? [] : "";
|
|
197
|
+
return shape === "catch-all" ? slug.split(SLUG_NESTED_DIVIDER) : slug;
|
|
546
198
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
199
|
+
|
|
200
|
+
// src/render/metadata/query.ts
|
|
201
|
+
import { getPayload } from "payload";
|
|
202
|
+
|
|
203
|
+
// src/collections/hooks/createRevalidateCollectionGlobalHook.ts
|
|
204
|
+
import { revalidateTag } from "next/cache";
|
|
205
|
+
function createRevalidateCollectionGlobalHook() {
|
|
206
|
+
const afterChangeDeleteHook = async ({ doc, req, ...args }) => {
|
|
207
|
+
const previousDoc = "previousDoc" in args ? args.previousDoc : null, locale = req.locale;
|
|
208
|
+
function revalidate(args2) {
|
|
209
|
+
try {
|
|
210
|
+
revalidateTag(createCollectionCacheKey({ ...args2, locale }), "max");
|
|
211
|
+
} catch (error) {
|
|
212
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
213
|
+
if (msg.includes("static generation store missing"))
|
|
214
|
+
return;
|
|
215
|
+
console.error(error);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if ("collection" in args) {
|
|
219
|
+
[
|
|
220
|
+
doc && doc._status !== "draft" && doc.slug,
|
|
221
|
+
previousDoc && previousDoc._status === "published" && previousDoc.slug
|
|
222
|
+
].filter((slug) => slug !== undefined && slug !== false).map((slug) => revalidate({ collectionSlug: args.collection.slug, slug }));
|
|
223
|
+
} else {
|
|
224
|
+
revalidate({ globalSlug: args.global.slug });
|
|
225
|
+
}
|
|
226
|
+
return doc;
|
|
561
227
|
};
|
|
228
|
+
return { afterChange: afterChangeDeleteHook, afterDelete: afterChangeDeleteHook };
|
|
562
229
|
}
|
|
563
|
-
function
|
|
564
|
-
|
|
565
|
-
name,
|
|
566
|
-
logo,
|
|
567
|
-
sameAs
|
|
568
|
-
}) {
|
|
569
|
-
console.log("[WWW] render/metadata:buildOrganizationLd siteUrl=", siteUrl, "name=", name, "logo?", Boolean(logo), "sameAs?", Boolean(sameAs));
|
|
570
|
-
const org = {
|
|
571
|
-
"@context": "https://schema.org",
|
|
572
|
-
"@type": "Organization",
|
|
573
|
-
"@id": `${siteUrl}#organization`,
|
|
574
|
-
url: siteUrl,
|
|
575
|
-
...name && { name },
|
|
576
|
-
...logo && { logo: { "@type": "ImageObject", url: logo } },
|
|
577
|
-
...sameAs && sameAs.length > 0 && { sameAs }
|
|
578
|
-
};
|
|
579
|
-
return org;
|
|
230
|
+
function createCollectionCacheKey(args) {
|
|
231
|
+
return `${"globalSlug" in args ? args.globalSlug : args.collectionSlug + args.slug}_${args.locale}`;
|
|
580
232
|
}
|
|
581
233
|
|
|
582
|
-
// src/render/metadata/
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
console.log("[WWW] render/metadata:segmentsToStoredSlug string passthrough:", JSON.stringify(segments));
|
|
587
|
-
return segments;
|
|
588
|
-
}
|
|
589
|
-
const result = nested ? segments.join(SLUG_NESTED_DIVIDER) : segments[0] ?? "";
|
|
590
|
-
console.log("[WWW] render/metadata:segmentsToStoredSlug nested=", nested, "segments=", JSON.stringify(segments), "->", result);
|
|
591
|
-
return result;
|
|
592
|
-
}
|
|
593
|
-
function segmentsToUrlPath(segments, nested) {
|
|
594
|
-
let result;
|
|
595
|
-
if (!Array.isArray(segments))
|
|
596
|
-
result = "/" + segments;
|
|
597
|
-
else if (nested)
|
|
598
|
-
result = "/" + segments.join("/");
|
|
599
|
-
else
|
|
600
|
-
result = "/" + (segments[0] ?? "");
|
|
601
|
-
console.log("[WWW] render/metadata:segmentsToUrlPath nested=", nested, "segments=", JSON.stringify(segments), "->", result);
|
|
602
|
-
return result;
|
|
603
|
-
}
|
|
604
|
-
function storedSlugToSegments(storedSlug, nested) {
|
|
605
|
-
const result = nested ? storedSlug.split(SLUG_NESTED_DIVIDER) : storedSlug;
|
|
606
|
-
console.log("[WWW] render/metadata:storedSlugToSegments nested=", nested, "storedSlug=", storedSlug, "->", JSON.stringify(result));
|
|
607
|
-
return result;
|
|
608
|
-
}
|
|
609
|
-
function buildCanonicalUrl({
|
|
610
|
-
siteUrl,
|
|
611
|
-
locale,
|
|
612
|
-
urlPrefix,
|
|
613
|
-
urlPath
|
|
614
|
-
}) {
|
|
615
|
-
const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
|
|
616
|
-
const prefixSegment = trimmedPrefix ? `/${trimmedPrefix}` : "";
|
|
617
|
-
const result = `${siteUrl}/${locale}${prefixSegment}${urlPath}`;
|
|
618
|
-
console.log("[WWW] render/metadata:buildCanonicalUrl siteUrl=", siteUrl, "locale=", locale, "urlPrefix=", urlPrefix, "urlPath=", urlPath, "->", result);
|
|
619
|
-
return result;
|
|
234
|
+
// src/render/metadata/query.ts
|
|
235
|
+
async function withUnstableCache(keyParts, tags, fn) {
|
|
236
|
+
const { unstable_cache } = await import("next/cache");
|
|
237
|
+
return unstable_cache(fn, keyParts.map(String), { tags })();
|
|
620
238
|
}
|
|
621
|
-
function
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
if (stored === homeSlug)
|
|
629
|
-
return "/";
|
|
630
|
-
}
|
|
631
|
-
return urlPath;
|
|
239
|
+
async function queryDoc(args, { config: configPromise }) {
|
|
240
|
+
return withUnstableCache(Object.values(args), [createCollectionCacheKey(args)], async () => {
|
|
241
|
+
if ("globalSlug" in args)
|
|
242
|
+
return queryGlobal({ ...args, config: configPromise });
|
|
243
|
+
else
|
|
244
|
+
return queryDocBySlug({ ...args, config: configPromise });
|
|
245
|
+
});
|
|
632
246
|
}
|
|
633
|
-
|
|
634
|
-
// src/render/metadata/query.ts
|
|
635
|
-
import { getPayload } from "payload";
|
|
636
|
-
import { cache } from "react";
|
|
637
|
-
var queryDocBySlug = cache(async function queryDocBySlug2({
|
|
247
|
+
async function queryDocBySlug({
|
|
638
248
|
collectionSlug,
|
|
639
249
|
slug,
|
|
640
250
|
slugField = "slug",
|
|
@@ -642,480 +252,252 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
|
|
|
642
252
|
draft = false,
|
|
643
253
|
config
|
|
644
254
|
}) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
255
|
+
return withUnstableCache([collectionSlug, slug, locale, draft], [createCollectionCacheKey({ collectionSlug, slug, locale })], async () => {
|
|
256
|
+
const payload = await getPayload({ config });
|
|
257
|
+
const result = await payload.find({
|
|
258
|
+
collection: collectionSlug,
|
|
259
|
+
draft,
|
|
260
|
+
limit: 1,
|
|
261
|
+
pagination: false,
|
|
262
|
+
overrideAccess: draft,
|
|
263
|
+
where: { [slugField]: { equals: slug } },
|
|
264
|
+
locale
|
|
265
|
+
});
|
|
266
|
+
return result.docs?.[0] ?? null;
|
|
655
267
|
});
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
});
|
|
660
|
-
var queryAllDocs = cache(async function queryAllDocs2({
|
|
661
|
-
collectionSlug,
|
|
662
|
-
slugField = "slug",
|
|
268
|
+
}
|
|
269
|
+
async function queryGlobal({
|
|
270
|
+
globalSlug,
|
|
663
271
|
locale,
|
|
272
|
+
draft = false,
|
|
664
273
|
config
|
|
665
274
|
}) {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
select: { [slugField]: true },
|
|
675
|
-
locale
|
|
275
|
+
return withUnstableCache([globalSlug, locale, draft], [createCollectionCacheKey({ globalSlug, locale })], async () => {
|
|
276
|
+
const payload = await getPayload({ config });
|
|
277
|
+
try {
|
|
278
|
+
return await payload.findGlobal({ slug: globalSlug, draft, locale });
|
|
279
|
+
} catch (error) {
|
|
280
|
+
console.warn("[WWW] queryGlobal failed", { globalSlug, locale, error: String(error) });
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
676
283
|
});
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
return docs;
|
|
680
|
-
});
|
|
681
|
-
var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
284
|
+
}
|
|
285
|
+
async function queryAllDocs({
|
|
682
286
|
collectionSlug,
|
|
683
|
-
slug,
|
|
684
287
|
slugField = "slug",
|
|
685
288
|
locale,
|
|
686
289
|
config
|
|
687
290
|
}) {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
collection: collectionSlug,
|
|
692
|
-
draft: false,
|
|
693
|
-
limit: 1,
|
|
694
|
-
pagination: false,
|
|
695
|
-
overrideAccess: false,
|
|
696
|
-
locale,
|
|
697
|
-
where: { [slugField]: { equals: slug } },
|
|
698
|
-
select: { [slugField]: true }
|
|
699
|
-
});
|
|
700
|
-
const doc = result.docs?.[0];
|
|
701
|
-
if (!doc) {
|
|
702
|
-
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> undefined (no doc)");
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
let fieldValue = doc[slugField];
|
|
706
|
-
if (doc.id != null) {
|
|
707
|
-
const allLocales = await payload.findByID({
|
|
291
|
+
return withUnstableCache([collectionSlug, slugField, locale], [createCollectionCacheKey({ collectionSlug, slug: "__all__", locale })], async () => {
|
|
292
|
+
const payload = await getPayload({ config });
|
|
293
|
+
const result = await payload.find({
|
|
708
294
|
collection: collectionSlug,
|
|
709
|
-
id: doc.id,
|
|
710
|
-
locale: "all",
|
|
711
295
|
draft: false,
|
|
296
|
+
limit: 1000,
|
|
297
|
+
pagination: false,
|
|
712
298
|
overrideAccess: false,
|
|
713
|
-
select: { [slugField]: true }
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
const rawLocales = Array.isArray(resolved?.localization?.localeCodes) ? resolved.localization.localeCodes : resolved?.localization?.locales?.map((l) => l.code) ?? [];
|
|
724
|
-
const out = {};
|
|
725
|
-
for (const l of rawLocales)
|
|
726
|
-
out[l] = String(fieldValue ?? slug);
|
|
727
|
-
console.log("[WWW] render/metadata:queryAllLocaleSlugs -> flat-fanout locales=", rawLocales.length, "slug=", JSON.stringify(fieldValue ?? slug));
|
|
728
|
-
return out;
|
|
729
|
-
});
|
|
730
|
-
var queryGlobal = cache(async function queryGlobal2({
|
|
731
|
-
globalSlug,
|
|
732
|
-
locale,
|
|
733
|
-
depth = 0,
|
|
734
|
-
draft = false,
|
|
299
|
+
select: { [slugField]: true },
|
|
300
|
+
locale
|
|
301
|
+
});
|
|
302
|
+
return result.docs ?? [];
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
async function queryAllLocaleSlugs({
|
|
306
|
+
collectionSlug,
|
|
307
|
+
id,
|
|
308
|
+
slugField = "slug",
|
|
735
309
|
config
|
|
736
310
|
}) {
|
|
737
|
-
console.log("[WWW] render/metadata:queryGlobal global=", globalSlug, "locale=", locale, "depth=", depth, "draft=", draft);
|
|
738
311
|
const payload = await getPayload({ config });
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
312
|
+
const doc = await payload.findByID({
|
|
313
|
+
collection: collectionSlug,
|
|
314
|
+
id,
|
|
315
|
+
locale: "all",
|
|
316
|
+
select: { [slugField]: true }
|
|
317
|
+
});
|
|
318
|
+
return doc?.[slugField];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// src/render/pages/createCollectionPageExports.tsx
|
|
322
|
+
import { setRequestLocale } from "next-intl/server";
|
|
323
|
+
|
|
324
|
+
// src/render/pages/utils/buildLocalizedPath.ts
|
|
325
|
+
function buildLocalizedPath(locale, prefix, slug, { routing }) {
|
|
326
|
+
return `${routing.localePrefix === "never" ? "" : routing.localePrefix === "always" ? locale : routing.localePrefix === "as-needed" ? locale === routing.defaultLocale ? "" : "/" + locale : (() => {
|
|
327
|
+
throw new Error("Unsupported locale prefix");
|
|
328
|
+
})()}${prefix ? "/" + prefix : ""}${slug ? "/" + slug : ""}`;
|
|
329
|
+
}
|
|
330
|
+
function buildLocalizedPaths(localesSlug, pagePathPrefix, { routing }) {
|
|
331
|
+
return routing.locales.reduce((paths, locale) => {
|
|
332
|
+
const slug = localesSlug[locale];
|
|
333
|
+
paths[locale] = buildLocalizedPath(locale, pagePathPrefix, slug, { routing });
|
|
334
|
+
return paths;
|
|
335
|
+
}, {});
|
|
336
|
+
}
|
|
337
|
+
function buildAlternates(locale, ...args) {
|
|
338
|
+
const siteUrl = args[2].siteUrl;
|
|
339
|
+
let localizedPaths = buildLocalizedPaths(...args);
|
|
340
|
+
localizedPaths["x-default"] = localizedPaths[args[2].routing.defaultLocale];
|
|
341
|
+
localizedPaths = Object.fromEntries(Object.entries(localizedPaths).map(([key, value]) => [key, siteUrl + localizedPaths[key]]));
|
|
342
|
+
return {
|
|
343
|
+
languages: localizedPaths,
|
|
344
|
+
canonical: localizedPaths[locale]
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// src/render/pages/createCollectionPageExports.tsx
|
|
349
|
+
import { createSiteDefaults, generateMeta } from "@justanarthur/payload-plugin-seo/next-metadata";
|
|
350
|
+
|
|
351
|
+
// package.json
|
|
352
|
+
var name = "@justanarthur/payload-www";
|
|
353
|
+
|
|
354
|
+
// src/render/renderWWWModule.tsx
|
|
355
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
356
|
+
async function renderWWWDataModule(data, {
|
|
357
|
+
collectionSlug,
|
|
358
|
+
configPath = "collections",
|
|
359
|
+
config: configPromise,
|
|
360
|
+
importMap
|
|
361
|
+
}, props) {
|
|
362
|
+
const config = await configPromise;
|
|
363
|
+
const renderPath = config[configPath]?.find((c) => c.slug === collectionSlug)?.custom?.[name]?.path;
|
|
364
|
+
const RenderModule = getFromImportMap(renderPath, importMap);
|
|
365
|
+
if (!RenderModule) {
|
|
366
|
+
if (false) {}
|
|
750
367
|
return null;
|
|
751
368
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
}
|
|
759
|
-
const mod = getFromImportMap(path, importMap);
|
|
760
|
-
const value = mod?.[exportName];
|
|
761
|
-
console.log("[WWW] render/metadata:getRenderModuleExports exportName=", exportName, "path=", path, "hit=", Boolean(value));
|
|
762
|
-
return value;
|
|
369
|
+
return /* @__PURE__ */ jsx5(RenderModule, {
|
|
370
|
+
data,
|
|
371
|
+
config,
|
|
372
|
+
importMap,
|
|
373
|
+
...props
|
|
374
|
+
});
|
|
763
375
|
}
|
|
764
376
|
|
|
765
377
|
// src/render/pages/createCollectionPageExports.tsx
|
|
766
|
-
import {
|
|
767
|
-
import { jsx as jsx8, jsxs as jsxs5, Fragment as Fragment6 } from "react/jsx-runtime";
|
|
768
|
-
var HOME_SLUG = "";
|
|
378
|
+
import { jsx as jsx6, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
769
379
|
function createCollectionPageExports({
|
|
770
|
-
slug = "pages",
|
|
380
|
+
slug: collectionSlug = "pages",
|
|
771
381
|
config: configPromise,
|
|
382
|
+
importMap,
|
|
772
383
|
routing,
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
const
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
metadataType: metadataTypeOverride,
|
|
783
|
-
showcase: showcaseOption,
|
|
784
|
-
homeExtras
|
|
785
|
-
} = deps;
|
|
786
|
-
const showcaseEnabled = showcaseOption?.enabled === true;
|
|
787
|
-
const { metadataHeading, jsonLdHeading } = showcaseOption ?? {};
|
|
788
|
-
const locales = routing.locales;
|
|
789
|
-
const defaultLocale = routing.defaultLocale;
|
|
790
|
-
const metadataType = metadataTypeOverride ?? (slug === POSTS_SLUG ? "article" : "website");
|
|
791
|
-
const defaultRenderPath = slug === POSTS_SLUG ? POSTS_RENDER_PATH : PAGES_RENDER_PATH;
|
|
792
|
-
const localePrefixMode = typeof routing.localePrefix === "string" ? routing.localePrefix : routing.localePrefix?.mode ?? "always";
|
|
793
|
-
const buildLocalePath = (locale, storedSlug) => {
|
|
794
|
-
const urlPath = getUrlPath(storedSlugToSegments(storedSlug, nested), nested, HOME_SLUG);
|
|
795
|
-
let result;
|
|
796
|
-
if (localePrefixMode === "never")
|
|
797
|
-
result = urlPath;
|
|
798
|
-
else if (localePrefixMode === "as-needed" && locale === defaultLocale)
|
|
799
|
-
result = urlPath;
|
|
800
|
-
else
|
|
801
|
-
result = `/${locale}${urlPath}`;
|
|
802
|
-
console.log("[WWW] render/pages:createCollectionPageExports:buildLocalePath locale=", locale, "storedSlug=", storedSlug, "->", result);
|
|
803
|
-
return result;
|
|
804
|
-
};
|
|
805
|
-
async function fetchDoc(locale, storedSlug, draft = false) {
|
|
806
|
-
return queryDocBySlug({
|
|
807
|
-
collectionSlug: slug,
|
|
808
|
-
slug: storedSlug,
|
|
384
|
+
slugShape = "single"
|
|
385
|
+
}, {
|
|
386
|
+
getServerSideURL,
|
|
387
|
+
pagePathPrefix
|
|
388
|
+
}) {
|
|
389
|
+
const siteUrl = getServerSideURL();
|
|
390
|
+
async function fetchDoc(locale, slug) {
|
|
391
|
+
return queryDoc({
|
|
392
|
+
slug,
|
|
809
393
|
locale,
|
|
810
|
-
|
|
394
|
+
collectionSlug
|
|
395
|
+
}, {
|
|
811
396
|
config: configPromise
|
|
812
397
|
});
|
|
813
398
|
}
|
|
814
|
-
async function resolveHreflangAlternates(locale, storedSlug) {
|
|
815
|
-
const siteUrl = getServerSideURL();
|
|
816
|
-
const urlPath = buildLocalePath(locale, storedSlug);
|
|
817
|
-
const canonical = `${siteUrl}${urlPath}`;
|
|
818
|
-
const languages = await buildHreflangAlternates({
|
|
819
|
-
siteUrl,
|
|
820
|
-
locale,
|
|
821
|
-
urlPrefix: "",
|
|
822
|
-
storedSlug,
|
|
823
|
-
nested,
|
|
824
|
-
homeSlug: HOME_SLUG,
|
|
825
|
-
defaultLocale,
|
|
826
|
-
locales,
|
|
827
|
-
localePrefix: localePrefixMode,
|
|
828
|
-
queryAllLocaleSlugs: (s, l) => queryAllLocaleSlugs({ collectionSlug: slug, slug: s, slugField: "slug", locale: l, config: configPromise })
|
|
829
|
-
});
|
|
830
|
-
const alternates = {};
|
|
831
|
-
for (const [key, url] of Object.entries(languages)) {
|
|
832
|
-
alternates[key] = url;
|
|
833
|
-
}
|
|
834
|
-
console.log("[WWW] render/pages:createCollectionPageExports:resolveHreflangAlternates canonical=", canonical, "alts=", JSON.stringify(alternates));
|
|
835
|
-
return { alternates, canonical };
|
|
836
|
-
}
|
|
837
399
|
const default_ = async (props) => {
|
|
838
|
-
const
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
-
console.log("[WWW] render/pages:createCollectionPageExports:default_ collectionSlug=", slug, "locale=", locale, "segments=", JSON.stringify(slugSegments), "showcase=", showcaseEnabled);
|
|
842
|
-
if (!locales.includes(locale)) {
|
|
843
|
-
console.error(`[WWW] render/pages:createCollectionPageExports:default_ notFound invalid-locale collection=${slug} locale=${locale} segments=${JSON.stringify(slugSegments)}`);
|
|
400
|
+
const params = await props.params;
|
|
401
|
+
const locale = params.locale;
|
|
402
|
+
if (!routing.locales.includes(locale)) {
|
|
844
403
|
const { notFound } = await import("next/navigation");
|
|
845
|
-
notFound();
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
const
|
|
850
|
-
const { isEnabled: draft } = await draftMode();
|
|
851
|
-
console.log("[WWW] render/pages:createCollectionPageExports:default_ draftMode=", draft);
|
|
852
|
-
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
853
|
-
const doc = await fetchDoc(locale, storedSlug, draft);
|
|
404
|
+
return notFound();
|
|
405
|
+
} else
|
|
406
|
+
setRequestLocale(locale);
|
|
407
|
+
const slug = paramsSlugToSlug(params.slug, slugShape);
|
|
408
|
+
const doc = await fetchDoc(locale, slug);
|
|
854
409
|
if (!doc) {
|
|
855
|
-
console.error(`[WWW] render/pages:createCollectionPageExports:default_ notFound no-doc collection=${slug} locale=${locale} storedSlug="${storedSlug}" segments=${JSON.stringify(slugSegments)} draft=${draft}`);
|
|
856
410
|
const { notFound } = await import("next/navigation");
|
|
857
411
|
notFound();
|
|
858
412
|
}
|
|
859
|
-
const
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
console.log("[WWW] render/pages:createCollectionPageExports:default_ effectivePath=", effectivePath);
|
|
863
|
-
const render = effectivePath === PAGES_RENDER_PATH ? /* @__PURE__ */ jsx8(PagesPage, {
|
|
864
|
-
doc,
|
|
865
|
-
importMap,
|
|
866
|
-
config: cfg,
|
|
867
|
-
locale
|
|
868
|
-
}) : effectivePath === POSTS_RENDER_PATH ? doc ? await renderPostBody(doc, locale) : null : renderCollectionModule(cfg.collections, slug, importMap, {
|
|
869
|
-
...props,
|
|
870
|
-
config: cfg,
|
|
871
|
-
locale,
|
|
872
|
-
searchParams: props.searchParams,
|
|
873
|
-
doc
|
|
874
|
-
});
|
|
875
|
-
const jsonLdNodes = doc ? await generateJsonLd(slugSegments, doc, locale) : [];
|
|
876
|
-
const { alternates: hreflangAlternates, canonical } = await resolveHreflangAlternates(locale, storedSlug);
|
|
877
|
-
const inner = /* @__PURE__ */ jsxs5(Fragment6, {
|
|
878
|
-
children: [
|
|
879
|
-
jsonLdNodes.map(({ id, schema }) => /* @__PURE__ */ jsx8("script", {
|
|
880
|
-
type: "application/ld+json",
|
|
881
|
-
dangerouslySetInnerHTML: { __html: JSON.stringify(schema) }
|
|
882
|
-
}, id)),
|
|
883
|
-
render,
|
|
884
|
-
draft ? (() => {
|
|
885
|
-
const ResolvedListener = importMap?.[LIVE_PREVIEW_LISTENER_PATH];
|
|
886
|
-
if (!ResolvedListener)
|
|
887
|
-
return null;
|
|
888
|
-
return /* @__PURE__ */ jsx8(Suspense, {
|
|
889
|
-
fallback: null,
|
|
890
|
-
children: /* @__PURE__ */ jsx8(ResolvedListener, {})
|
|
891
|
-
});
|
|
892
|
-
})() : null,
|
|
893
|
-
storedSlug === HOME_SLUG && homeExtras ? await homeExtras({ locale, doc }) : null
|
|
894
|
-
]
|
|
895
|
-
});
|
|
896
|
-
if (!showcaseEnabled || !doc)
|
|
897
|
-
return inner;
|
|
898
|
-
const { PageShowcase: PageShowcase2 } = await Promise.resolve().then(() => (init_PageShowcase(), exports_PageShowcase));
|
|
899
|
-
const { LocaleSwitcher: LocaleSwitcher2 } = await Promise.resolve().then(() => (init_LocaleSwitcher(), exports_LocaleSwitcher));
|
|
900
|
-
const meta = await generateMeta({
|
|
901
|
-
doc,
|
|
902
|
-
url: canonical,
|
|
903
|
-
type: metadataType,
|
|
904
|
-
locale
|
|
905
|
-
});
|
|
906
|
-
return /* @__PURE__ */ jsx8(PageShowcase2, {
|
|
907
|
-
metadata: meta,
|
|
908
|
-
metadataHeading,
|
|
909
|
-
jsonLdHeading,
|
|
910
|
-
jsonLd: jsonLdNodes,
|
|
911
|
-
localeSwitcher: /* @__PURE__ */ jsx8(LocaleSwitcher2, {
|
|
912
|
-
currentLocale: locale,
|
|
913
|
-
hreflangAlternates,
|
|
914
|
-
labels: routing.labels
|
|
915
|
-
}),
|
|
916
|
-
children: inner
|
|
413
|
+
const rendered = renderWWWDataModule(doc, { collectionSlug, config: configPromise, importMap }, { ...props, locale });
|
|
414
|
+
return /* @__PURE__ */ jsx6(Fragment2, {
|
|
415
|
+
children: rendered
|
|
917
416
|
});
|
|
918
417
|
};
|
|
919
418
|
async function generateMetadata(props) {
|
|
920
|
-
const
|
|
921
|
-
const
|
|
922
|
-
const
|
|
923
|
-
const
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
if (!doc)
|
|
932
|
-
console.log("[WWW] render/pages:createCollectionPageExports:generateMetadata no doc -> not found meta");
|
|
933
|
-
return { title: "Not found", robots: { index: false, follow: false } };
|
|
934
|
-
}
|
|
935
|
-
const collection = cfg.collections.find((c) => c.slug === slug);
|
|
936
|
-
if (!collection) {
|
|
937
|
-
console.warn("[WWW] render/pages:createCollectionPageExports:generateMetadata collection not in config slug=", slug);
|
|
419
|
+
const params = await props.params;
|
|
420
|
+
const locale = params.locale, slug = paramsSlugToSlug(params.slug, slugShape);
|
|
421
|
+
const doc = await fetchDoc(locale, slug);
|
|
422
|
+
const [localesSlug, siteDefaults] = await Promise.all([
|
|
423
|
+
doc ? queryAllLocaleSlugs({
|
|
424
|
+
id: doc.id,
|
|
425
|
+
collectionSlug,
|
|
426
|
+
config: configPromise
|
|
427
|
+
}) : Promise.resolve({}),
|
|
428
|
+
createSiteDefaults({ config: configPromise, locale })
|
|
429
|
+
]);
|
|
430
|
+
if (!doc)
|
|
938
431
|
return {};
|
|
939
|
-
}
|
|
940
|
-
const { canonical, alternates } = await resolveHreflangAlternates(locale, storedSlug);
|
|
432
|
+
const alternates = buildAlternates(locale, localesSlug ?? {}, pagePathPrefix, { routing, siteUrl });
|
|
941
433
|
const meta = await generateMeta({
|
|
942
|
-
doc,
|
|
943
|
-
url: canonical,
|
|
944
|
-
type:
|
|
945
|
-
locale
|
|
434
|
+
meta: doc.meta,
|
|
435
|
+
url: alternates.canonical,
|
|
436
|
+
type: "website",
|
|
437
|
+
locale,
|
|
438
|
+
availableLocales: routing.locales,
|
|
439
|
+
fallback: doc,
|
|
440
|
+
siteDefaults
|
|
946
441
|
});
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
languages: Object.keys(alternates).length ? alternates : undefined
|
|
950
|
-
};
|
|
951
|
-
return meta;
|
|
442
|
+
console.log("[www#generateMetadata]", { alternates, meta, locale, localesSlug, doc });
|
|
443
|
+
return { ...meta, alternates };
|
|
952
444
|
}
|
|
953
|
-
async function
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
958
|
-
const urlPath = buildLocalePath(locale, storedSlug);
|
|
959
|
-
const canonical = `${siteUrl}${urlPath}`;
|
|
960
|
-
const entries = Array.isArray(jsonLdOption) ? jsonLdOption : metadataType === "article" ? [{ type: "article" }] : [{ type: "website" }];
|
|
961
|
-
console.log("[WWW] render/pages:createCollectionPageExports:generateJsonLd collection=", slug, "locale=", locale, "entries=", entries.map((e) => e.type).join(","));
|
|
962
|
-
const outputs = [];
|
|
963
|
-
for (const entry of entries) {
|
|
964
|
-
const id = entry.id ?? `jsonld-${entry.type}-${outputs.length}`;
|
|
965
|
-
let schema = null;
|
|
966
|
-
switch (entry.type) {
|
|
967
|
-
case "article": {
|
|
968
|
-
const articleOpts = {
|
|
969
|
-
doc,
|
|
970
|
-
url: canonical,
|
|
971
|
-
locale,
|
|
972
|
-
siteUrl,
|
|
973
|
-
type: entry.schemaType ?? "BlogPosting"
|
|
974
|
-
};
|
|
975
|
-
if (entry.publisherName !== undefined)
|
|
976
|
-
articleOpts.publisherName = entry.publisherName;
|
|
977
|
-
if (entry.publisherLogo !== undefined)
|
|
978
|
-
articleOpts.publisherLogo = entry.publisherLogo;
|
|
979
|
-
schema = buildArticleLd(articleOpts);
|
|
980
|
-
break;
|
|
981
|
-
}
|
|
982
|
-
case "website": {
|
|
983
|
-
schema = {
|
|
984
|
-
"@context": "https://schema.org",
|
|
985
|
-
"@type": "WebSite",
|
|
986
|
-
"@id": `${siteUrl}#website`,
|
|
987
|
-
url: siteUrl,
|
|
988
|
-
name: entry.name ?? websiteName ?? new URL(siteUrl).hostname,
|
|
989
|
-
...entry.alternateName ? { alternateName: entry.alternateName } : {},
|
|
990
|
-
inLanguage: locale
|
|
991
|
-
};
|
|
992
|
-
break;
|
|
993
|
-
}
|
|
994
|
-
case "organization": {
|
|
995
|
-
schema = buildOrganizationLd({
|
|
996
|
-
siteUrl,
|
|
997
|
-
name: entry.name,
|
|
998
|
-
logo: entry.logo,
|
|
999
|
-
sameAs: entry.sameAs
|
|
1000
|
-
});
|
|
1001
|
-
break;
|
|
1002
|
-
}
|
|
1003
|
-
case "breadcrumbs": {
|
|
1004
|
-
let items = entry.items ?? [];
|
|
1005
|
-
if (!items.length && entry.buildItems)
|
|
1006
|
-
items = entry.buildItems(doc, canonical);
|
|
1007
|
-
if (items.length > 0)
|
|
1008
|
-
schema = buildBreadcrumbsLd({ items, currentUrl: canonical });
|
|
1009
|
-
break;
|
|
1010
|
-
}
|
|
1011
|
-
case "custom": {
|
|
1012
|
-
schema = entry.build({ doc, url: canonical, locale, siteUrl });
|
|
1013
|
-
break;
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
if (schema)
|
|
1017
|
-
outputs.push({ id, schema });
|
|
1018
|
-
}
|
|
1019
|
-
return outputs;
|
|
1020
|
-
}
|
|
1021
|
-
async function generateStaticParams() {
|
|
1022
|
-
console.log("[WWW] render/pages:createCollectionPageExports:generateStaticParams collection=", slug, "locales=", JSON.stringify(locales));
|
|
1023
|
-
const params = [];
|
|
1024
|
-
for (const locale of locales) {
|
|
1025
|
-
const docs = await queryAllDocs({ collectionSlug: slug, slugField: "slug", locale, config: configPromise });
|
|
1026
|
-
for (const doc of docs) {
|
|
1027
|
-
const slugVal = doc.slug;
|
|
1028
|
-
if (typeof slugVal !== "string" || slugVal === "")
|
|
1029
|
-
continue;
|
|
1030
|
-
const segments = storedSlugToSegments(slugVal, nested);
|
|
1031
|
-
params.push({ slug: Array.isArray(segments) ? segments : [segments], locale });
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
console.log("[WWW] render/pages:createCollectionPageExports:generateStaticParams -> count=", params.length);
|
|
1035
|
-
return params;
|
|
445
|
+
async function generateStaticParams(props) {
|
|
446
|
+
const locale = (await props.params).locale;
|
|
447
|
+
const docs = await queryAllDocs({ locale, collectionSlug, config: configPromise });
|
|
448
|
+
return docs.filter((doc) => typeof doc.slug === "string" && doc.slug.length > 0).map((doc) => ({ slug: slugToParamsSlug(doc.slug, slugShape) }));
|
|
1036
449
|
}
|
|
1037
450
|
async function generateSitemap() {
|
|
1038
|
-
|
|
451
|
+
const locale = routing.defaultLocale;
|
|
1039
452
|
const docs = await queryAllDocs({
|
|
1040
|
-
collectionSlug
|
|
1041
|
-
|
|
1042
|
-
locale: defaultLocale,
|
|
453
|
+
collectionSlug,
|
|
454
|
+
locale,
|
|
1043
455
|
config: configPromise
|
|
1044
456
|
});
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
console.log("[WWW] render/pages:createCollectionPageExports:generateSitemap -> urls=", urls.length);
|
|
1059
|
-
return urls;
|
|
457
|
+
return await Promise.all(docs.map(async (doc) => {
|
|
458
|
+
const localesSlug = await queryAllLocaleSlugs({
|
|
459
|
+
id: doc.id,
|
|
460
|
+
collectionSlug,
|
|
461
|
+
config: configPromise
|
|
462
|
+
}) ?? {};
|
|
463
|
+
const alternates = buildAlternates(locale, localesSlug, pagePathPrefix, { routing, siteUrl });
|
|
464
|
+
return {
|
|
465
|
+
url: alternates.canonical,
|
|
466
|
+
alternates,
|
|
467
|
+
lastModified: doc.updatedAt || new Date
|
|
468
|
+
};
|
|
469
|
+
}));
|
|
1060
470
|
}
|
|
471
|
+
generateSitemap.getServerSideURL = getServerSideURL;
|
|
472
|
+
generateSitemap.pagePathPrefix = pagePathPrefix;
|
|
1061
473
|
return {
|
|
1062
474
|
default: default_,
|
|
1063
475
|
generateMetadata,
|
|
1064
476
|
generateStaticParams,
|
|
1065
|
-
generateSitemap
|
|
1066
|
-
generateJsonLd
|
|
477
|
+
generateSitemap
|
|
1067
478
|
};
|
|
1068
479
|
}
|
|
1069
|
-
function
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
className: "posts-page prose prose-neutral dark:prose-invert mx-auto max-w-3xl py-10",
|
|
1083
|
-
children: [
|
|
1084
|
-
/* @__PURE__ */ jsxs5("header", {
|
|
1085
|
-
className: "posts-page__header not-prose mb-8",
|
|
1086
|
-
children: [
|
|
1087
|
-
/* @__PURE__ */ jsx8("h1", {
|
|
1088
|
-
className: "posts-page__title text-4xl font-semibold tracking-tight",
|
|
1089
|
-
children: title
|
|
1090
|
-
}),
|
|
1091
|
-
excerpt ? /* @__PURE__ */ jsx8("p", {
|
|
1092
|
-
className: "posts-page__excerpt mt-3 text-lg text-muted-foreground",
|
|
1093
|
-
children: excerpt
|
|
1094
|
-
}) : null
|
|
1095
|
-
]
|
|
1096
|
-
}),
|
|
1097
|
-
content ? /* @__PURE__ */ jsx8("div", {
|
|
1098
|
-
className: "posts-page__content",
|
|
1099
|
-
children: /* @__PURE__ */ jsx8(RichText, {
|
|
1100
|
-
data: content
|
|
1101
|
-
})
|
|
1102
|
-
}) : null
|
|
1103
|
-
]
|
|
1104
|
-
});
|
|
480
|
+
function createSitemapFromCollections(...args) {
|
|
481
|
+
const baseUrl = args[0].getServerSideURL();
|
|
482
|
+
return function sitemap() {
|
|
483
|
+
const sitemaps = args.map((arg) => `${baseUrl}/${arg.pagePathPrefix}/sitemap.xml`);
|
|
484
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
485
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
486
|
+
${sitemaps.map((url) => ` <sitemap><loc>${url}</loc></sitemap>`).join(`
|
|
487
|
+
`)}
|
|
488
|
+
</sitemapindex>`;
|
|
489
|
+
return new Response(xml, {
|
|
490
|
+
headers: { "Content-Type": "application/xml" }
|
|
491
|
+
});
|
|
492
|
+
};
|
|
1105
493
|
}
|
|
1106
494
|
|
|
1107
495
|
// src/exports/pages.ts
|
|
1108
|
-
var
|
|
1109
|
-
|
|
1110
|
-
addCollectionsToSitemap,
|
|
1111
|
-
PagesPage,
|
|
1112
|
-
HeaderPage,
|
|
1113
|
-
FooterPage
|
|
1114
|
-
};
|
|
496
|
+
var pages = { createCollectionPageExports, PagesPage, HeaderPage, FooterPage };
|
|
497
|
+
var pages_default = pages;
|
|
1115
498
|
export {
|
|
1116
499
|
pages_default as default,
|
|
1117
500
|
createCollectionPageExports,
|
|
1118
|
-
addCollectionsToSitemap,
|
|
1119
501
|
PagesPage,
|
|
1120
502
|
HeaderPage,
|
|
1121
503
|
FooterPage
|