@justanarthur/payload-www 0.1.2 → 0.3.0
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 +2 -1
- package/dist/collections.d.ts +31 -2
- package/dist/collections.js +28 -38
- package/dist/config.d.ts +8 -0
- package/dist/config.js +55 -50
- package/dist/core-fields.d.ts +38 -1
- package/dist/core-fields.js +35 -2
- package/dist/data-collections.d.ts +31 -2
- package/dist/data-collections.js +28 -38
- package/dist/data-test.js +55 -50
- package/dist/fields.d.ts +38 -1
- package/dist/fields.js +35 -2
- package/dist/globals.d.ts +23 -2
- package/dist/globals.js +21 -7
- package/dist/metadata.js +13 -1
- package/dist/pages.d.ts +14 -1
- package/dist/pages.js +21 -9
- package/dist/render-metadata.js +13 -1
- package/dist/render-pages.d.ts +14 -1
- package/dist/render-pages.js +21 -9
- package/dist/render-utils.d.ts +8 -0
- package/dist/render-utils.js +17 -3
- package/dist/server.d.ts +65 -7
- package/dist/server.js +68 -63
- package/dist/test.js +55 -50
- package/dist/with-www-config.d.ts +8 -0
- package/dist/with-www-config.js +55 -50
- package/package.json +1 -1
package/dist/globals.js
CHANGED
|
@@ -36,7 +36,8 @@ var link = (options = {}) => {
|
|
|
36
36
|
disableLabel = false,
|
|
37
37
|
relationTo = [PAGES_SLUG],
|
|
38
38
|
localized = false,
|
|
39
|
-
overrides = {}
|
|
39
|
+
overrides = {},
|
|
40
|
+
extraFields = []
|
|
40
41
|
} = options;
|
|
41
42
|
const result = {
|
|
42
43
|
name: "link",
|
|
@@ -113,6 +114,9 @@ var link = (options = {}) => {
|
|
|
113
114
|
options: opts
|
|
114
115
|
});
|
|
115
116
|
}
|
|
117
|
+
if (extraFields.length) {
|
|
118
|
+
result.fields.push(...extraFields);
|
|
119
|
+
}
|
|
116
120
|
return { ...result, ...overrides };
|
|
117
121
|
};
|
|
118
122
|
|
|
@@ -157,17 +161,22 @@ function createRevalidateGlobalHook(slug) {
|
|
|
157
161
|
|
|
158
162
|
// src/data/collections/globals/Header/config.ts
|
|
159
163
|
var createHeaderGlobal = (options = {}) => {
|
|
160
|
-
const {
|
|
164
|
+
const {
|
|
165
|
+
renderPath = HEADER_RENDER_PATH,
|
|
166
|
+
linkRelationTo = [PAGES_SLUG],
|
|
167
|
+
navColumnLinkFields = [],
|
|
168
|
+
navItemLinkFields = []
|
|
169
|
+
} = options;
|
|
161
170
|
const navColumnBlock = {
|
|
162
171
|
slug: "navColumn",
|
|
163
172
|
fields: [
|
|
164
173
|
{ name: "title", type: "text", required: true, localized: true },
|
|
165
|
-
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })] }
|
|
174
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
166
175
|
]
|
|
167
176
|
};
|
|
168
177
|
const navItemBlock = {
|
|
169
178
|
slug: "navItem",
|
|
170
|
-
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })]
|
|
179
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
171
180
|
};
|
|
172
181
|
return {
|
|
173
182
|
slug: "header",
|
|
@@ -189,17 +198,22 @@ var createHeaderGlobal = (options = {}) => {
|
|
|
189
198
|
|
|
190
199
|
// src/data/collections/globals/Footer/config.ts
|
|
191
200
|
var createFooterGlobal = (options = {}) => {
|
|
192
|
-
const {
|
|
201
|
+
const {
|
|
202
|
+
renderPath = FOOTER_RENDER_PATH,
|
|
203
|
+
linkRelationTo = [PAGES_SLUG],
|
|
204
|
+
navColumnLinkFields = [],
|
|
205
|
+
navItemLinkFields = []
|
|
206
|
+
} = options;
|
|
193
207
|
const navColumnBlock = {
|
|
194
208
|
slug: "navColumn",
|
|
195
209
|
fields: [
|
|
196
210
|
{ name: "title", type: "text", required: true, localized: true },
|
|
197
|
-
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })] }
|
|
211
|
+
{ name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
|
|
198
212
|
]
|
|
199
213
|
};
|
|
200
214
|
const navItemBlock = {
|
|
201
215
|
slug: "navItem",
|
|
202
|
-
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })]
|
|
216
|
+
fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
|
|
203
217
|
};
|
|
204
218
|
return {
|
|
205
219
|
slug: "footer",
|
package/dist/metadata.js
CHANGED
|
@@ -262,7 +262,19 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
262
262
|
const doc = result.docs?.[0];
|
|
263
263
|
if (!doc)
|
|
264
264
|
return;
|
|
265
|
-
|
|
265
|
+
let fieldValue = doc[slugField];
|
|
266
|
+
if (doc.id != null) {
|
|
267
|
+
const allLocales = await payload.findByID({
|
|
268
|
+
collection: collectionSlug,
|
|
269
|
+
id: doc.id,
|
|
270
|
+
locale: "all",
|
|
271
|
+
draft: false,
|
|
272
|
+
overrideAccess: false,
|
|
273
|
+
select: { [slugField]: true }
|
|
274
|
+
}).catch(() => null);
|
|
275
|
+
if (allLocales)
|
|
276
|
+
fieldValue = allLocales[slugField];
|
|
277
|
+
}
|
|
266
278
|
if (fieldValue && typeof fieldValue === "object") {
|
|
267
279
|
return fieldValue;
|
|
268
280
|
}
|
package/dist/pages.d.ts
CHANGED
|
@@ -207,6 +207,19 @@ type CreateCollectionPageExportsArgs<S extends string = "pages"> = {
|
|
|
207
207
|
* defined your own Server Component for the collection.
|
|
208
208
|
*/
|
|
209
209
|
renderPath?: string;
|
|
210
|
+
/**
|
|
211
|
+
* Enable nested (hierarchical) slugs. When `true`, the catch-all
|
|
212
|
+
* `[...slug]` segments are joined with the `_` divider to form the
|
|
213
|
+
* stored slug (URL `/about/us` ⇄ stored `about_us`), URL paths and
|
|
214
|
+
* hreflang alternates are expanded back to `/about/us`, and
|
|
215
|
+
* `generateStaticParams` emits multi-segment params. When `false`
|
|
216
|
+
* (the default) only the first URL segment is used — flat slugs.
|
|
217
|
+
*
|
|
218
|
+
* Pair with `createPagesCollection({ nested: true })` (or
|
|
219
|
+
* `createWWWConfig({ nested: true })`) so the collection's slug
|
|
220
|
+
* validation accepts the `_` divider.
|
|
221
|
+
*/
|
|
222
|
+
nested?: boolean;
|
|
210
223
|
};
|
|
211
224
|
type CreateCollectionPageExportsDeps<S extends string> = {
|
|
212
225
|
/**
|
|
@@ -285,7 +298,7 @@ type CreateCollectionPageExportsDeps<S extends string> = {
|
|
|
285
298
|
* { generateMetadata, generateStaticParams }
|
|
286
299
|
* Page
|
|
287
300
|
*/
|
|
288
|
-
declare function createCollectionPageExports<S extends string = "pages">({ slug, config: configPromise, routing, importMap: importMapArg, renderPath }: CreateCollectionPageExportsArgs<S>, deps: CreateCollectionPageExportsDeps<S>, options?: MetadataOptions): {
|
|
301
|
+
declare function createCollectionPageExports<S extends string = "pages">({ slug, config: configPromise, routing, importMap: importMapArg, renderPath, nested }: CreateCollectionPageExportsArgs<S>, deps: CreateCollectionPageExportsDeps<S>, options?: MetadataOptions): {
|
|
289
302
|
default: (props: {
|
|
290
303
|
params: Promise<{
|
|
291
304
|
locale?: string;
|
package/dist/pages.js
CHANGED
|
@@ -639,7 +639,19 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
639
639
|
const doc = result.docs?.[0];
|
|
640
640
|
if (!doc)
|
|
641
641
|
return;
|
|
642
|
-
|
|
642
|
+
let fieldValue = doc[slugField];
|
|
643
|
+
if (doc.id != null) {
|
|
644
|
+
const allLocales = await payload.findByID({
|
|
645
|
+
collection: collectionSlug,
|
|
646
|
+
id: doc.id,
|
|
647
|
+
locale: "all",
|
|
648
|
+
draft: false,
|
|
649
|
+
overrideAccess: false,
|
|
650
|
+
select: { [slugField]: true }
|
|
651
|
+
}).catch(() => null);
|
|
652
|
+
if (allLocales)
|
|
653
|
+
fieldValue = allLocales[slugField];
|
|
654
|
+
}
|
|
643
655
|
if (fieldValue && typeof fieldValue === "object") {
|
|
644
656
|
return fieldValue;
|
|
645
657
|
}
|
|
@@ -687,7 +699,8 @@ function createCollectionPageExports({
|
|
|
687
699
|
config: configPromise,
|
|
688
700
|
routing,
|
|
689
701
|
importMap: importMapArg,
|
|
690
|
-
renderPath
|
|
702
|
+
renderPath,
|
|
703
|
+
nested = false
|
|
691
704
|
}, deps, options = {}) {
|
|
692
705
|
const importMap = importMapArg ?? {};
|
|
693
706
|
const { jsonLd: jsonLdOption = true, changefreq = "weekly", priority = 0.5, websiteName } = options;
|
|
@@ -706,7 +719,7 @@ function createCollectionPageExports({
|
|
|
706
719
|
const defaultRenderPath = slug === POSTS_SLUG ? POSTS_RENDER_PATH : PAGES_RENDER_PATH;
|
|
707
720
|
const localePrefixMode = typeof routing.localePrefix === "string" ? routing.localePrefix : routing.localePrefix?.mode ?? "always";
|
|
708
721
|
const buildLocalePath = (locale, storedSlug) => {
|
|
709
|
-
const urlPath = getUrlPath(storedSlug,
|
|
722
|
+
const urlPath = getUrlPath(storedSlugToSegments(storedSlug, nested), nested, HOME_SLUG);
|
|
710
723
|
if (localePrefixMode === "never")
|
|
711
724
|
return urlPath;
|
|
712
725
|
if (localePrefixMode === "as-needed" && locale === defaultLocale)
|
|
@@ -731,7 +744,7 @@ function createCollectionPageExports({
|
|
|
731
744
|
locale,
|
|
732
745
|
urlPrefix: "",
|
|
733
746
|
storedSlug,
|
|
734
|
-
nested
|
|
747
|
+
nested,
|
|
735
748
|
homeSlug: HOME_SLUG,
|
|
736
749
|
defaultLocale,
|
|
737
750
|
locales,
|
|
@@ -756,7 +769,7 @@ function createCollectionPageExports({
|
|
|
756
769
|
setRequestLocale(locale);
|
|
757
770
|
const { draftMode } = await import("next/headers");
|
|
758
771
|
const { isEnabled: draft } = await draftMode();
|
|
759
|
-
const storedSlug = segmentsToStoredSlug(slugSegments,
|
|
772
|
+
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
760
773
|
const doc = await fetchDoc(locale, storedSlug, draft);
|
|
761
774
|
if (!doc) {
|
|
762
775
|
const { notFound } = await import("next/navigation");
|
|
@@ -779,7 +792,6 @@ function createCollectionPageExports({
|
|
|
779
792
|
});
|
|
780
793
|
const jsonLdNodes = doc ? await generateJsonLd(slugSegments, doc, locale) : [];
|
|
781
794
|
const { alternates: hreflangAlternates, canonical } = await resolveHreflangAlternates(locale, storedSlug);
|
|
782
|
-
console.log("render", { render, doc });
|
|
783
795
|
const inner = /* @__PURE__ */ jsxs5(Fragment6, {
|
|
784
796
|
children: [
|
|
785
797
|
jsonLdNodes.map(({ id, schema }) => /* @__PURE__ */ jsx8("script", {
|
|
@@ -829,7 +841,7 @@ function createCollectionPageExports({
|
|
|
829
841
|
const locale = typeof incomingLocale === "string" ? incomingLocale : defaultLocale;
|
|
830
842
|
if (!locales.includes(locale))
|
|
831
843
|
return { title: "Not found", robots: { index: false, follow: false } };
|
|
832
|
-
const storedSlug = segmentsToStoredSlug(slugSegments,
|
|
844
|
+
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
833
845
|
const doc = await fetchDoc(locale, storedSlug);
|
|
834
846
|
if (!doc)
|
|
835
847
|
return { title: "Not found", robots: { index: false, follow: false } };
|
|
@@ -853,7 +865,7 @@ function createCollectionPageExports({
|
|
|
853
865
|
if (jsonLdOption === false || !doc)
|
|
854
866
|
return [];
|
|
855
867
|
const siteUrl = getServerSideURL();
|
|
856
|
-
const storedSlug = segmentsToStoredSlug(slugSegments,
|
|
868
|
+
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
857
869
|
const urlPath = buildLocalePath(locale, storedSlug);
|
|
858
870
|
const canonical = `${siteUrl}${urlPath}`;
|
|
859
871
|
const entries = Array.isArray(jsonLdOption) ? jsonLdOption : metadataType === "article" ? [{ type: "article" }] : [{ type: "website" }];
|
|
@@ -924,7 +936,7 @@ function createCollectionPageExports({
|
|
|
924
936
|
const slugVal = doc.slug;
|
|
925
937
|
if (typeof slugVal !== "string" || slugVal === "")
|
|
926
938
|
continue;
|
|
927
|
-
const segments = storedSlugToSegments(slugVal,
|
|
939
|
+
const segments = storedSlugToSegments(slugVal, nested);
|
|
928
940
|
params.push({ slug: Array.isArray(segments) ? segments : [segments], locale });
|
|
929
941
|
}
|
|
930
942
|
}
|
package/dist/render-metadata.js
CHANGED
|
@@ -262,7 +262,19 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
262
262
|
const doc = result.docs?.[0];
|
|
263
263
|
if (!doc)
|
|
264
264
|
return;
|
|
265
|
-
|
|
265
|
+
let fieldValue = doc[slugField];
|
|
266
|
+
if (doc.id != null) {
|
|
267
|
+
const allLocales = await payload.findByID({
|
|
268
|
+
collection: collectionSlug,
|
|
269
|
+
id: doc.id,
|
|
270
|
+
locale: "all",
|
|
271
|
+
draft: false,
|
|
272
|
+
overrideAccess: false,
|
|
273
|
+
select: { [slugField]: true }
|
|
274
|
+
}).catch(() => null);
|
|
275
|
+
if (allLocales)
|
|
276
|
+
fieldValue = allLocales[slugField];
|
|
277
|
+
}
|
|
266
278
|
if (fieldValue && typeof fieldValue === "object") {
|
|
267
279
|
return fieldValue;
|
|
268
280
|
}
|
package/dist/render-pages.d.ts
CHANGED
|
@@ -130,6 +130,19 @@ type CreateCollectionPageExportsArgs<S extends string = "pages"> = {
|
|
|
130
130
|
* defined your own Server Component for the collection.
|
|
131
131
|
*/
|
|
132
132
|
renderPath?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Enable nested (hierarchical) slugs. When `true`, the catch-all
|
|
135
|
+
* `[...slug]` segments are joined with the `_` divider to form the
|
|
136
|
+
* stored slug (URL `/about/us` ⇄ stored `about_us`), URL paths and
|
|
137
|
+
* hreflang alternates are expanded back to `/about/us`, and
|
|
138
|
+
* `generateStaticParams` emits multi-segment params. When `false`
|
|
139
|
+
* (the default) only the first URL segment is used — flat slugs.
|
|
140
|
+
*
|
|
141
|
+
* Pair with `createPagesCollection({ nested: true })` (or
|
|
142
|
+
* `createWWWConfig({ nested: true })`) so the collection's slug
|
|
143
|
+
* validation accepts the `_` divider.
|
|
144
|
+
*/
|
|
145
|
+
nested?: boolean;
|
|
133
146
|
};
|
|
134
147
|
type CreateCollectionPageExportsDeps<S extends string> = {
|
|
135
148
|
/**
|
|
@@ -208,7 +221,7 @@ type CreateCollectionPageExportsDeps<S extends string> = {
|
|
|
208
221
|
* { generateMetadata, generateStaticParams }
|
|
209
222
|
* Page
|
|
210
223
|
*/
|
|
211
|
-
declare function createCollectionPageExports<S extends string = "pages">({ slug, config: configPromise, routing, importMap: importMapArg, renderPath }: CreateCollectionPageExportsArgs<S>, deps: CreateCollectionPageExportsDeps<S>, options?: MetadataOptions): {
|
|
224
|
+
declare function createCollectionPageExports<S extends string = "pages">({ slug, config: configPromise, routing, importMap: importMapArg, renderPath, nested }: CreateCollectionPageExportsArgs<S>, deps: CreateCollectionPageExportsDeps<S>, options?: MetadataOptions): {
|
|
212
225
|
default: (props: {
|
|
213
226
|
params: Promise<{
|
|
214
227
|
locale?: string;
|
package/dist/render-pages.js
CHANGED
|
@@ -460,7 +460,19 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
460
460
|
const doc = result.docs?.[0];
|
|
461
461
|
if (!doc)
|
|
462
462
|
return;
|
|
463
|
-
|
|
463
|
+
let fieldValue = doc[slugField];
|
|
464
|
+
if (doc.id != null) {
|
|
465
|
+
const allLocales = await payload.findByID({
|
|
466
|
+
collection: collectionSlug,
|
|
467
|
+
id: doc.id,
|
|
468
|
+
locale: "all",
|
|
469
|
+
draft: false,
|
|
470
|
+
overrideAccess: false,
|
|
471
|
+
select: { [slugField]: true }
|
|
472
|
+
}).catch(() => null);
|
|
473
|
+
if (allLocales)
|
|
474
|
+
fieldValue = allLocales[slugField];
|
|
475
|
+
}
|
|
464
476
|
if (fieldValue && typeof fieldValue === "object") {
|
|
465
477
|
return fieldValue;
|
|
466
478
|
}
|
|
@@ -571,7 +583,8 @@ function createCollectionPageExports({
|
|
|
571
583
|
config: configPromise,
|
|
572
584
|
routing,
|
|
573
585
|
importMap: importMapArg,
|
|
574
|
-
renderPath
|
|
586
|
+
renderPath,
|
|
587
|
+
nested = false
|
|
575
588
|
}, deps, options = {}) {
|
|
576
589
|
const importMap = importMapArg ?? {};
|
|
577
590
|
const { jsonLd: jsonLdOption = true, changefreq = "weekly", priority = 0.5, websiteName } = options;
|
|
@@ -590,7 +603,7 @@ function createCollectionPageExports({
|
|
|
590
603
|
const defaultRenderPath = slug === POSTS_SLUG ? POSTS_RENDER_PATH : PAGES_RENDER_PATH;
|
|
591
604
|
const localePrefixMode = typeof routing.localePrefix === "string" ? routing.localePrefix : routing.localePrefix?.mode ?? "always";
|
|
592
605
|
const buildLocalePath = (locale, storedSlug) => {
|
|
593
|
-
const urlPath = getUrlPath(storedSlug,
|
|
606
|
+
const urlPath = getUrlPath(storedSlugToSegments(storedSlug, nested), nested, HOME_SLUG);
|
|
594
607
|
if (localePrefixMode === "never")
|
|
595
608
|
return urlPath;
|
|
596
609
|
if (localePrefixMode === "as-needed" && locale === defaultLocale)
|
|
@@ -615,7 +628,7 @@ function createCollectionPageExports({
|
|
|
615
628
|
locale,
|
|
616
629
|
urlPrefix: "",
|
|
617
630
|
storedSlug,
|
|
618
|
-
nested
|
|
631
|
+
nested,
|
|
619
632
|
homeSlug: HOME_SLUG,
|
|
620
633
|
defaultLocale,
|
|
621
634
|
locales,
|
|
@@ -640,7 +653,7 @@ function createCollectionPageExports({
|
|
|
640
653
|
setRequestLocale(locale);
|
|
641
654
|
const { draftMode } = await import("next/headers");
|
|
642
655
|
const { isEnabled: draft } = await draftMode();
|
|
643
|
-
const storedSlug = segmentsToStoredSlug(slugSegments,
|
|
656
|
+
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
644
657
|
const doc = await fetchDoc(locale, storedSlug, draft);
|
|
645
658
|
if (!doc) {
|
|
646
659
|
const { notFound } = await import("next/navigation");
|
|
@@ -663,7 +676,6 @@ function createCollectionPageExports({
|
|
|
663
676
|
});
|
|
664
677
|
const jsonLdNodes = doc ? await generateJsonLd(slugSegments, doc, locale) : [];
|
|
665
678
|
const { alternates: hreflangAlternates, canonical } = await resolveHreflangAlternates(locale, storedSlug);
|
|
666
|
-
console.log("render", { render, doc });
|
|
667
679
|
const inner = /* @__PURE__ */ jsxs3(Fragment4, {
|
|
668
680
|
children: [
|
|
669
681
|
jsonLdNodes.map(({ id, schema }) => /* @__PURE__ */ jsx6("script", {
|
|
@@ -713,7 +725,7 @@ function createCollectionPageExports({
|
|
|
713
725
|
const locale = typeof incomingLocale === "string" ? incomingLocale : defaultLocale;
|
|
714
726
|
if (!locales.includes(locale))
|
|
715
727
|
return { title: "Not found", robots: { index: false, follow: false } };
|
|
716
|
-
const storedSlug = segmentsToStoredSlug(slugSegments,
|
|
728
|
+
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
717
729
|
const doc = await fetchDoc(locale, storedSlug);
|
|
718
730
|
if (!doc)
|
|
719
731
|
return { title: "Not found", robots: { index: false, follow: false } };
|
|
@@ -737,7 +749,7 @@ function createCollectionPageExports({
|
|
|
737
749
|
if (jsonLdOption === false || !doc)
|
|
738
750
|
return [];
|
|
739
751
|
const siteUrl = getServerSideURL();
|
|
740
|
-
const storedSlug = segmentsToStoredSlug(slugSegments,
|
|
752
|
+
const storedSlug = segmentsToStoredSlug(slugSegments, nested);
|
|
741
753
|
const urlPath = buildLocalePath(locale, storedSlug);
|
|
742
754
|
const canonical = `${siteUrl}${urlPath}`;
|
|
743
755
|
const entries = Array.isArray(jsonLdOption) ? jsonLdOption : metadataType === "article" ? [{ type: "article" }] : [{ type: "website" }];
|
|
@@ -808,7 +820,7 @@ function createCollectionPageExports({
|
|
|
808
820
|
const slugVal = doc.slug;
|
|
809
821
|
if (typeof slugVal !== "string" || slugVal === "")
|
|
810
822
|
continue;
|
|
811
|
-
const segments = storedSlugToSegments(slugVal,
|
|
823
|
+
const segments = storedSlugToSegments(slugVal, nested);
|
|
812
824
|
params.push({ slug: Array.isArray(segments) ? segments : [segments], locale });
|
|
813
825
|
}
|
|
814
826
|
}
|
package/dist/render-utils.d.ts
CHANGED
|
@@ -89,6 +89,14 @@ type CreateSitemapFileOptions = {
|
|
|
89
89
|
priority?: number;
|
|
90
90
|
changefreq?: "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never";
|
|
91
91
|
}>;
|
|
92
|
+
/**
|
|
93
|
+
* Per-collection nested-slug flag. When a collection is marked
|
|
94
|
+
* `true`, its stored `about_us` slug is expanded into the
|
|
95
|
+
* `/about/us` URL path (and hreflang alternates), matching a
|
|
96
|
+
* `createCollectionPageExports({ nested: true })` route. Defaults
|
|
97
|
+
* to `false` (flat slugs) for every collection.
|
|
98
|
+
*/
|
|
99
|
+
nested?: Record<string, boolean>;
|
|
92
100
|
};
|
|
93
101
|
/**
|
|
94
102
|
* A Next.js sitemap function for the host's
|
package/dist/render-utils.js
CHANGED
|
@@ -226,7 +226,19 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
|
|
|
226
226
|
const doc = result.docs?.[0];
|
|
227
227
|
if (!doc)
|
|
228
228
|
return;
|
|
229
|
-
|
|
229
|
+
let fieldValue = doc[slugField];
|
|
230
|
+
if (doc.id != null) {
|
|
231
|
+
const allLocales2 = await payload.findByID({
|
|
232
|
+
collection: collectionSlug,
|
|
233
|
+
id: doc.id,
|
|
234
|
+
locale: "all",
|
|
235
|
+
draft: false,
|
|
236
|
+
overrideAccess: false,
|
|
237
|
+
select: { [slugField]: true }
|
|
238
|
+
}).catch(() => null);
|
|
239
|
+
if (allLocales2)
|
|
240
|
+
fieldValue = allLocales2[slugField];
|
|
241
|
+
}
|
|
230
242
|
if (fieldValue && typeof fieldValue === "object") {
|
|
231
243
|
return fieldValue;
|
|
232
244
|
}
|
|
@@ -279,6 +291,7 @@ function createSitemapFile(options) {
|
|
|
279
291
|
const collectionDefaults = options.perCollection?.[collectionSlug] ?? {};
|
|
280
292
|
const urlPrefix = (options.urlPrefixes?.[collectionSlug] ?? "").replace(/\/$/, "");
|
|
281
293
|
const siteUrl = options.getServerSideURL().replace(/\/$/, "");
|
|
294
|
+
const isNested = options.nested?.[collectionSlug] ?? false;
|
|
282
295
|
for (const locale of activeLocales) {
|
|
283
296
|
const docs = await queryAllDocs({
|
|
284
297
|
collectionSlug,
|
|
@@ -294,13 +307,14 @@ function createSitemapFile(options) {
|
|
|
294
307
|
if (seen.has(dedupeKey))
|
|
295
308
|
continue;
|
|
296
309
|
seen.add(dedupeKey);
|
|
297
|
-
const
|
|
310
|
+
const slugPath = isNested ? storedSlug.replaceAll("_", "/") : storedSlug;
|
|
311
|
+
const url = `${siteUrl}${prefixFor(locale, defaultLocale, options.localePrefix ?? "always")}${urlPrefix}/${slugPath}`;
|
|
298
312
|
const languages = await buildHreflangAlternates({
|
|
299
313
|
siteUrl,
|
|
300
314
|
locale,
|
|
301
315
|
urlPrefix,
|
|
302
316
|
storedSlug,
|
|
303
|
-
nested:
|
|
317
|
+
nested: isNested,
|
|
304
318
|
homeSlug: "",
|
|
305
319
|
defaultLocale,
|
|
306
320
|
locales: activeLocales,
|
package/dist/server.d.ts
CHANGED
|
@@ -156,6 +156,19 @@ type CreateCollectionPageExportsArgs<S extends string = "pages"> = {
|
|
|
156
156
|
* defined your own Server Component for the collection.
|
|
157
157
|
*/
|
|
158
158
|
renderPath?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Enable nested (hierarchical) slugs. When `true`, the catch-all
|
|
161
|
+
* `[...slug]` segments are joined with the `_` divider to form the
|
|
162
|
+
* stored slug (URL `/about/us` ⇄ stored `about_us`), URL paths and
|
|
163
|
+
* hreflang alternates are expanded back to `/about/us`, and
|
|
164
|
+
* `generateStaticParams` emits multi-segment params. When `false`
|
|
165
|
+
* (the default) only the first URL segment is used — flat slugs.
|
|
166
|
+
*
|
|
167
|
+
* Pair with `createPagesCollection({ nested: true })` (or
|
|
168
|
+
* `createWWWConfig({ nested: true })`) so the collection's slug
|
|
169
|
+
* validation accepts the `_` divider.
|
|
170
|
+
*/
|
|
171
|
+
nested?: boolean;
|
|
159
172
|
};
|
|
160
173
|
type CreateCollectionPageExportsDeps<S extends string> = {
|
|
161
174
|
/**
|
|
@@ -234,7 +247,7 @@ type CreateCollectionPageExportsDeps<S extends string> = {
|
|
|
234
247
|
* { generateMetadata, generateStaticParams }
|
|
235
248
|
* Page
|
|
236
249
|
*/
|
|
237
|
-
declare function createCollectionPageExports<S extends string = "pages">({ slug, config: configPromise, routing, importMap: importMapArg, renderPath }: CreateCollectionPageExportsArgs<S>, deps: CreateCollectionPageExportsDeps<S>, options?: MetadataOptions): {
|
|
250
|
+
declare function createCollectionPageExports<S extends string = "pages">({ slug, config: configPromise, routing, importMap: importMapArg, renderPath, nested }: CreateCollectionPageExportsArgs<S>, deps: CreateCollectionPageExportsDeps<S>, options?: MetadataOptions): {
|
|
238
251
|
default: (props: {
|
|
239
252
|
params: Promise<{
|
|
240
253
|
locale?: string;
|
|
@@ -382,6 +395,14 @@ type CreatePagesCollectionOptions = {
|
|
|
382
395
|
* when omitted.
|
|
383
396
|
*/
|
|
384
397
|
defaultLocale?: CreateRevalidateCollectionHookOptions["defaultLocale"];
|
|
398
|
+
/**
|
|
399
|
+
* Enable nested (hierarchical) slugs. When `true`, the slug field
|
|
400
|
+
* additionally accepts the `_` nesting divider (so `about_us`
|
|
401
|
+
* renders at `/about/us`) and the admin description documents the
|
|
402
|
+
* convention. Pair with `createCollectionPageExports({ nested: true })`
|
|
403
|
+
* on the matching route. Default: `false` (flat, hyphen-only slugs).
|
|
404
|
+
*/
|
|
405
|
+
nested?: boolean;
|
|
385
406
|
};
|
|
386
407
|
declare const createPagesCollection: (blocks: Block[], options?: Omit<CreatePagesCollectionOptions, "blocks">) => CollectionConfig;
|
|
387
408
|
import { CollectionConfig as CollectionConfig2 } from "payload";
|
|
@@ -439,7 +460,7 @@ type CreateStaticPagesCollectionOptions = {
|
|
|
439
460
|
blocks: Block2[];
|
|
440
461
|
};
|
|
441
462
|
declare const createStaticPagesCollection: (blocks: Block2[]) => CollectionConfig3;
|
|
442
|
-
import { GlobalConfig } from "payload";
|
|
463
|
+
import { Field, GlobalConfig } from "payload";
|
|
443
464
|
type CreateHeaderGlobalOptions = {
|
|
444
465
|
/**
|
|
445
466
|
* Optional override for the `custom.path` Payload uses to resolve
|
|
@@ -453,6 +474,17 @@ type CreateHeaderGlobalOptions = {
|
|
|
453
474
|
* different list when your host has additional linkable collections.
|
|
454
475
|
*/
|
|
455
476
|
linkRelationTo?: string[];
|
|
477
|
+
/**
|
|
478
|
+
* Extra fields appended to each `navColumn` link — e.g. a
|
|
479
|
+
* `description` text field or a `navHover` group for a mega-menu.
|
|
480
|
+
* Lets hosts enrich the column-link schema without redefining the
|
|
481
|
+
* whole nav.
|
|
482
|
+
*/
|
|
483
|
+
navColumnLinkFields?: Field[];
|
|
484
|
+
/**
|
|
485
|
+
* Extra fields appended to each top-level `navItem` link.
|
|
486
|
+
*/
|
|
487
|
+
navItemLinkFields?: Field[];
|
|
456
488
|
};
|
|
457
489
|
/**
|
|
458
490
|
* Build the Header global. The lib's default shape: a `nav` blocks
|
|
@@ -460,7 +492,7 @@ type CreateHeaderGlobalOptions = {
|
|
|
460
492
|
* and `navItem` (a single link).
|
|
461
493
|
*/
|
|
462
494
|
declare const createHeaderGlobal: (options?: CreateHeaderGlobalOptions) => GlobalConfig;
|
|
463
|
-
import { GlobalConfig as GlobalConfig2 } from "payload";
|
|
495
|
+
import { Field as Field2, GlobalConfig as GlobalConfig2 } from "payload";
|
|
464
496
|
type CreateFooterGlobalOptions = {
|
|
465
497
|
/**
|
|
466
498
|
* Optional override for the `custom.path` Payload uses to resolve
|
|
@@ -474,6 +506,16 @@ type CreateFooterGlobalOptions = {
|
|
|
474
506
|
* different list when your host has additional linkable collections.
|
|
475
507
|
*/
|
|
476
508
|
linkRelationTo?: string[];
|
|
509
|
+
/**
|
|
510
|
+
* Extra fields appended to each `navColumn` link — e.g. a
|
|
511
|
+
* `description` text field. Lets hosts enrich the column-link
|
|
512
|
+
* schema without redefining the whole nav.
|
|
513
|
+
*/
|
|
514
|
+
navColumnLinkFields?: Field2[];
|
|
515
|
+
/**
|
|
516
|
+
* Extra fields appended to each top-level `navItem` link.
|
|
517
|
+
*/
|
|
518
|
+
navItemLinkFields?: Field2[];
|
|
477
519
|
};
|
|
478
520
|
/**
|
|
479
521
|
* Build the Footer global. The lib's default shape mirrors the
|
|
@@ -517,6 +559,14 @@ type WWWConfigOptions = {
|
|
|
517
559
|
*/
|
|
518
560
|
registerPosts?: boolean;
|
|
519
561
|
/**
|
|
562
|
+
* Enable nested (hierarchical) Pages slugs. When `true`, the lib's
|
|
563
|
+
* Pages collection accepts the `_` nesting divider in its slug
|
|
564
|
+
* (`about_us` → `/about/us`). Pass the same `nested: true` to
|
|
565
|
+
* `createCollectionPageExports` on the Pages route so URL building,
|
|
566
|
+
* hreflang, and static params expand the divider. Default: `false`.
|
|
567
|
+
*/
|
|
568
|
+
nested?: boolean;
|
|
569
|
+
/**
|
|
520
570
|
* Final say on the lib's default plugin list. Receives the
|
|
521
571
|
* `[seoPlugin, imageHashPlugin, translator]` array; return the
|
|
522
572
|
* list to apply. Common uses: drop the translator (no AI
|
|
@@ -575,7 +625,7 @@ import { GlobalAfterChangeHook } from "payload";
|
|
|
575
625
|
* uses.
|
|
576
626
|
*/
|
|
577
627
|
declare function createRevalidateGlobalHook(slug: string): GlobalAfterChangeHook;
|
|
578
|
-
import { Field, GroupField } from "payload";
|
|
628
|
+
import { Field as Field3, GroupField } from "payload";
|
|
579
629
|
type LinkAppearances = "default" | "outline";
|
|
580
630
|
declare const appearanceOptions: Record<LinkAppearances, {
|
|
581
631
|
label: string;
|
|
@@ -597,10 +647,18 @@ type LinkOptions = {
|
|
|
597
647
|
overrides?: Partial<GroupField>;
|
|
598
648
|
/** Legacy alias for the host's custom field overrides. */
|
|
599
649
|
linkOverrides?: Partial<GroupField>;
|
|
650
|
+
/**
|
|
651
|
+
* Extra fields appended to the link group — e.g. a `description`
|
|
652
|
+
* text field or a `navHover` group for a mega-menu. Lets hosts
|
|
653
|
+
* extend the nav link schema without re-implementing the whole
|
|
654
|
+
* `link` field. Appended after the standard type/label/appearance
|
|
655
|
+
* fields.
|
|
656
|
+
*/
|
|
657
|
+
extraFields?: Field3[];
|
|
600
658
|
};
|
|
601
|
-
declare const link: (options?: LinkOptions) =>
|
|
602
|
-
import { Field as
|
|
603
|
-
declare const linkGroup: (options?: LinkOptions) =>
|
|
659
|
+
declare const link: (options?: LinkOptions) => Field3;
|
|
660
|
+
import { Field as Field4 } from "payload";
|
|
661
|
+
declare const linkGroup: (options?: LinkOptions) => Field4;
|
|
604
662
|
import { ImportMap as ImportMap2 } from "payload";
|
|
605
663
|
declare function getFromImportMap(key: string, importMap: ImportMap2): any;
|
|
606
664
|
declare function generateImportName(type: "block" | "page", slug: string): string;
|