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