@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/dist/server.js CHANGED
@@ -192,7 +192,6 @@ var authenticatedOrPublished = ({ req: { user } }) => {
192
192
  return true;
193
193
  return { _status: { equals: "published" } };
194
194
  };
195
-
196
195
  // src/render/_locale.ts
197
196
  function prefixFor(locale, defaultLocale, mode) {
198
197
  if (mode === "never")
@@ -364,24 +363,9 @@ var createPagesCollection = (blocks, options = {}) => {
364
363
  renderPath = PAGES_RENDER_PATH,
365
364
  slug: collectionSlug = PAGES_SLUG2,
366
365
  localePrefix,
367
- defaultLocale
366
+ defaultLocale,
367
+ nested = false
368
368
  } = options;
369
- const slugField = {
370
- name: "slug",
371
- type: "text",
372
- required: true,
373
- unique: true,
374
- index: true,
375
- admin: { position: "sidebar" },
376
- validate: (value) => {
377
- if (typeof value !== "string")
378
- return "Slug must be a string";
379
- if (value !== "" && !/^[a-z0-9-]+$/.test(value)) {
380
- return "Slug must be lowercase, with hyphens (no spaces or special characters)";
381
- }
382
- return true;
383
- }
384
- };
385
369
  const baseFields = [
386
370
  {
387
371
  name: "title",
@@ -411,7 +395,7 @@ var createPagesCollection = (blocks, options = {}) => {
411
395
  type: "date",
412
396
  admin: { position: "sidebar" }
413
397
  },
414
- slugField
398
+ slugField({ nested })
415
399
  ];
416
400
  const { afterChange: revalidateAfterChange, afterDelete: revalidateAfterDelete } = createRevalidateCollectionHook({
417
401
  collectionSlug,
@@ -446,14 +430,6 @@ var createPostsCollection = (options = {}) => {
446
430
  localePrefix,
447
431
  defaultLocale
448
432
  } = options;
449
- const slugField = {
450
- name: "slug",
451
- type: "text",
452
- required: true,
453
- unique: true,
454
- index: true,
455
- admin: { position: "sidebar" }
456
- };
457
433
  const baseFields = [
458
434
  {
459
435
  name: "title",
@@ -478,7 +454,7 @@ var createPostsCollection = (options = {}) => {
478
454
  type: "date",
479
455
  admin: { position: "sidebar" }
480
456
  },
481
- slugField
457
+ slugField()
482
458
  ];
483
459
  const { afterChange, afterDelete } = createRevalidateCollectionHook({
484
460
  collectionSlug,
@@ -579,17 +555,18 @@ var createStaticPagesCollection = (blocks) => {
579
555
  };
580
556
 
581
557
  // src/core/fields/link.ts
582
- var appearanceOptions = {
558
+ var appearanceOptions2 = {
583
559
  default: { label: "Default", value: "default" },
584
560
  outline: { label: "Outline", value: "outline" }
585
561
  };
586
- var link = (options = {}) => {
562
+ var link2 = (options = {}) => {
587
563
  const {
588
564
  appearances,
589
565
  disableLabel = false,
590
566
  relationTo = [PAGES_SLUG],
591
567
  localized = false,
592
- overrides = {}
568
+ overrides = {},
569
+ extraFields = []
593
570
  } = options;
594
571
  const result = {
595
572
  name: "link",
@@ -657,7 +634,7 @@ var link = (options = {}) => {
657
634
  result.fields = [...result.fields, ...linkTypes];
658
635
  }
659
636
  if (appearances !== false) {
660
- const opts = appearances ? appearances.map((a) => appearanceOptions[a]) : [appearanceOptions.default, appearanceOptions.outline];
637
+ const opts = appearances ? appearances.map((a) => appearanceOptions2[a]) : [appearanceOptions2.default, appearanceOptions2.outline];
661
638
  result.fields.push({
662
639
  name: "appearance",
663
640
  type: "select",
@@ -666,6 +643,9 @@ var link = (options = {}) => {
666
643
  options: opts
667
644
  });
668
645
  }
646
+ if (extraFields.length) {
647
+ result.fields.push(...extraFields);
648
+ }
669
649
  return { ...result, ...overrides };
670
650
  };
671
651
 
@@ -685,17 +665,22 @@ function createRevalidateGlobalHook(slug) {
685
665
 
686
666
  // src/data/collections/globals/Header/config.ts
687
667
  var createHeaderGlobal = (options = {}) => {
688
- const { renderPath = HEADER_RENDER_PATH, linkRelationTo = [PAGES_SLUG] } = options;
668
+ const {
669
+ renderPath = HEADER_RENDER_PATH,
670
+ linkRelationTo = [PAGES_SLUG],
671
+ navColumnLinkFields = [],
672
+ navItemLinkFields = []
673
+ } = options;
689
674
  const navColumnBlock = {
690
675
  slug: "navColumn",
691
676
  fields: [
692
677
  { name: "title", type: "text", required: true, localized: true },
693
- { name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })] }
678
+ { name: "links", type: "array", fields: [link2({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
694
679
  ]
695
680
  };
696
681
  const navItemBlock = {
697
682
  slug: "navItem",
698
- fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })]
683
+ fields: [link2({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
699
684
  };
700
685
  return {
701
686
  slug: "header",
@@ -717,17 +702,22 @@ var createHeaderGlobal = (options = {}) => {
717
702
 
718
703
  // src/data/collections/globals/Footer/config.ts
719
704
  var createFooterGlobal = (options = {}) => {
720
- const { renderPath = FOOTER_RENDER_PATH, linkRelationTo = [PAGES_SLUG] } = options;
705
+ const {
706
+ renderPath = FOOTER_RENDER_PATH,
707
+ linkRelationTo = [PAGES_SLUG],
708
+ navColumnLinkFields = [],
709
+ navItemLinkFields = []
710
+ } = options;
721
711
  const navColumnBlock = {
722
712
  slug: "navColumn",
723
713
  fields: [
724
714
  { name: "title", type: "text", required: true, localized: true },
725
- { name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })] }
715
+ { name: "links", type: "array", fields: [link2({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
726
716
  ]
727
717
  };
728
718
  const navItemBlock = {
729
719
  slug: "navItem",
730
- fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })]
720
+ fields: [link2({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
731
721
  };
732
722
  return {
733
723
  slug: "footer",
@@ -816,7 +806,7 @@ function getFromImportMap(key, importMap) {
816
806
  var queryDocBySlug = cache(async function queryDocBySlug2({
817
807
  collectionSlug,
818
808
  slug,
819
- slugField = "slug",
809
+ slugField: slugField2 = "slug",
820
810
  locale,
821
811
  draft = false,
822
812
  config
@@ -828,14 +818,14 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
828
818
  limit: 1,
829
819
  pagination: false,
830
820
  overrideAccess: draft,
831
- where: { [slugField]: { equals: slug } },
821
+ where: { [slugField2]: { equals: slug } },
832
822
  locale
833
823
  });
834
824
  return result.docs?.[0] ?? null;
835
825
  });
836
826
  var queryAllDocs = cache(async function queryAllDocs2({
837
827
  collectionSlug,
838
- slugField = "slug",
828
+ slugField: slugField2 = "slug",
839
829
  locale,
840
830
  config
841
831
  }) {
@@ -846,7 +836,7 @@ var queryAllDocs = cache(async function queryAllDocs2({
846
836
  limit: 1000,
847
837
  pagination: false,
848
838
  overrideAccess: false,
849
- select: { [slugField]: true },
839
+ select: { [slugField2]: true },
850
840
  locale
851
841
  });
852
842
  return result.docs ?? [];
@@ -854,7 +844,7 @@ var queryAllDocs = cache(async function queryAllDocs2({
854
844
  var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
855
845
  collectionSlug,
856
846
  slug,
857
- slugField = "slug",
847
+ slugField: slugField2 = "slug",
858
848
  locale,
859
849
  config
860
850
  }) {
@@ -866,13 +856,25 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
866
856
  pagination: false,
867
857
  overrideAccess: false,
868
858
  locale,
869
- where: { [slugField]: { equals: slug } },
870
- select: { [slugField]: true }
859
+ where: { [slugField2]: { equals: slug } },
860
+ select: { [slugField2]: true }
871
861
  });
872
862
  const doc = result.docs?.[0];
873
863
  if (!doc)
874
864
  return;
875
- const fieldValue = doc?.[slugField];
865
+ let fieldValue = doc[slugField2];
866
+ if (doc.id != null) {
867
+ const allLocales2 = await payload.findByID({
868
+ collection: collectionSlug,
869
+ id: doc.id,
870
+ locale: "all",
871
+ draft: false,
872
+ overrideAccess: false,
873
+ select: { [slugField2]: true }
874
+ }).catch(() => null);
875
+ if (allLocales2)
876
+ fieldValue = allLocales2[slugField2];
877
+ }
876
878
  if (fieldValue && typeof fieldValue === "object") {
877
879
  return fieldValue;
878
880
  }
@@ -925,6 +927,7 @@ function createSitemapFile(options) {
925
927
  const collectionDefaults = options.perCollection?.[collectionSlug] ?? {};
926
928
  const urlPrefix = (options.urlPrefixes?.[collectionSlug] ?? "").replace(/\/$/, "");
927
929
  const siteUrl = options.getServerSideURL().replace(/\/$/, "");
930
+ const isNested = options.nested?.[collectionSlug] ?? false;
928
931
  for (const locale of activeLocales) {
929
932
  const docs = await queryAllDocs({
930
933
  collectionSlug,
@@ -940,13 +943,14 @@ function createSitemapFile(options) {
940
943
  if (seen.has(dedupeKey))
941
944
  continue;
942
945
  seen.add(dedupeKey);
943
- const url = `${siteUrl}${prefixFor(locale, defaultLocale, options.localePrefix ?? "always")}${urlPrefix}/${storedSlug}`;
946
+ const slugPath = isNested ? storedSlug.replaceAll("_", "/") : storedSlug;
947
+ const url = `${siteUrl}${prefixFor(locale, defaultLocale, options.localePrefix ?? "always")}${urlPrefix}/${slugPath}`;
944
948
  const languages = await buildHreflangAlternates({
945
949
  siteUrl,
946
950
  locale,
947
951
  urlPrefix,
948
952
  storedSlug,
949
- nested: false,
953
+ nested: isNested,
950
954
  homeSlug: "",
951
955
  defaultLocale,
952
956
  locales: activeLocales,
@@ -977,7 +981,7 @@ function createSitemapFile(options) {
977
981
  }
978
982
  // src/config/createWWWConfig.ts
979
983
  function createWWWConfig(options) {
980
- const { locales, routing, blocks, linkRelationTo, registerPosts = true, defaultPlugins } = options;
984
+ const { locales, routing, blocks, linkRelationTo, registerPosts = true, nested = false, defaultPlugins } = options;
981
985
  const defaultLocale = routing?.defaultLocale ?? locales[0] ?? "";
982
986
  const localePrefixMode = (() => {
983
987
  const raw = routing?.localePrefix;
@@ -990,7 +994,8 @@ function createWWWConfig(options) {
990
994
  }
991
995
  const buildPagesCollection = () => createPagesCollection(blocks, {
992
996
  localePrefix: localePrefixMode,
993
- defaultLocale
997
+ defaultLocale,
998
+ nested
994
999
  });
995
1000
  const buildPostsCollection = () => createPostsCollection({
996
1001
  localePrefix: localePrefixMode,
@@ -1076,10 +1081,10 @@ function createWWWConfig(options) {
1076
1081
  }
1077
1082
 
1078
1083
  // src/core/fields/linkGroup.ts
1079
- var linkGroup = (options = {}) => ({
1084
+ var linkGroup2 = (options = {}) => ({
1080
1085
  name: "links",
1081
1086
  type: "array",
1082
- fields: [link(options)],
1087
+ fields: [link2(options)],
1083
1088
  admin: { initCollapsed: true }
1084
1089
  });
1085
1090
 
@@ -1635,7 +1640,8 @@ function createCollectionPageExports({
1635
1640
  config: configPromise,
1636
1641
  routing,
1637
1642
  importMap: importMapArg,
1638
- renderPath
1643
+ renderPath,
1644
+ nested = false
1639
1645
  }, deps, options = {}) {
1640
1646
  const importMap = importMapArg ?? {};
1641
1647
  const { jsonLd: jsonLdOption = true, changefreq = "weekly", priority = 0.5, websiteName } = options;
@@ -1654,7 +1660,7 @@ function createCollectionPageExports({
1654
1660
  const defaultRenderPath = slug === POSTS_SLUG ? POSTS_RENDER_PATH : PAGES_RENDER_PATH;
1655
1661
  const localePrefixMode = typeof routing.localePrefix === "string" ? routing.localePrefix : routing.localePrefix?.mode ?? "always";
1656
1662
  const buildLocalePath = (locale, storedSlug) => {
1657
- const urlPath = getUrlPath(storedSlug, false, HOME_SLUG);
1663
+ const urlPath = getUrlPath(storedSlugToSegments(storedSlug, nested), nested, HOME_SLUG);
1658
1664
  if (localePrefixMode === "never")
1659
1665
  return urlPath;
1660
1666
  if (localePrefixMode === "as-needed" && locale === defaultLocale)
@@ -1679,7 +1685,7 @@ function createCollectionPageExports({
1679
1685
  locale,
1680
1686
  urlPrefix: "",
1681
1687
  storedSlug,
1682
- nested: false,
1688
+ nested,
1683
1689
  homeSlug: HOME_SLUG,
1684
1690
  defaultLocale,
1685
1691
  locales,
@@ -1704,7 +1710,7 @@ function createCollectionPageExports({
1704
1710
  setRequestLocale(locale);
1705
1711
  const { draftMode } = await import("next/headers");
1706
1712
  const { isEnabled: draft } = await draftMode();
1707
- const storedSlug = segmentsToStoredSlug(slugSegments, false);
1713
+ const storedSlug = segmentsToStoredSlug(slugSegments, nested);
1708
1714
  const doc = await fetchDoc(locale, storedSlug, draft);
1709
1715
  if (!doc) {
1710
1716
  const { notFound } = await import("next/navigation");
@@ -1727,7 +1733,6 @@ function createCollectionPageExports({
1727
1733
  });
1728
1734
  const jsonLdNodes = doc ? await generateJsonLd(slugSegments, doc, locale) : [];
1729
1735
  const { alternates: hreflangAlternates, canonical } = await resolveHreflangAlternates(locale, storedSlug);
1730
- console.log("render", { render, doc });
1731
1736
  const inner = /* @__PURE__ */ jsxs3(Fragment4, {
1732
1737
  children: [
1733
1738
  jsonLdNodes.map(({ id, schema }) => /* @__PURE__ */ jsx7("script", {
@@ -1777,7 +1782,7 @@ function createCollectionPageExports({
1777
1782
  const locale = typeof incomingLocale === "string" ? incomingLocale : defaultLocale;
1778
1783
  if (!locales.includes(locale))
1779
1784
  return { title: "Not found", robots: { index: false, follow: false } };
1780
- const storedSlug = segmentsToStoredSlug(slugSegments, false);
1785
+ const storedSlug = segmentsToStoredSlug(slugSegments, nested);
1781
1786
  const doc = await fetchDoc(locale, storedSlug);
1782
1787
  if (!doc)
1783
1788
  return { title: "Not found", robots: { index: false, follow: false } };
@@ -1801,7 +1806,7 @@ function createCollectionPageExports({
1801
1806
  if (jsonLdOption === false || !doc)
1802
1807
  return [];
1803
1808
  const siteUrl = getServerSideURL();
1804
- const storedSlug = segmentsToStoredSlug(slugSegments, false);
1809
+ const storedSlug = segmentsToStoredSlug(slugSegments, nested);
1805
1810
  const urlPath = buildLocalePath(locale, storedSlug);
1806
1811
  const canonical = `${siteUrl}${urlPath}`;
1807
1812
  const entries = Array.isArray(jsonLdOption) ? jsonLdOption : metadataType === "article" ? [{ type: "article" }] : [{ type: "website" }];
@@ -1872,7 +1877,7 @@ function createCollectionPageExports({
1872
1877
  const slugVal = doc.slug;
1873
1878
  if (typeof slugVal !== "string" || slugVal === "")
1874
1879
  continue;
1875
- const segments = storedSlugToSegments(slugVal, false);
1880
+ const segments = storedSlugToSegments(slugVal, nested);
1876
1881
  params.push({ slug: Array.isArray(segments) ? segments : [segments], locale });
1877
1882
  }
1878
1883
  }
@@ -2015,8 +2020,8 @@ export {
2015
2020
  queryDocBySlug,
2016
2021
  queryAllLocaleSlugs,
2017
2022
  queryAllDocs,
2018
- linkGroup,
2019
- link,
2023
+ linkGroup2 as linkGroup,
2024
+ link2 as link,
2020
2025
  getUrlPath,
2021
2026
  getRenderModuleExports,
2022
2027
  getFromImportMap,
@@ -2044,7 +2049,7 @@ export {
2044
2049
  buildArticleLd,
2045
2050
  authenticatedOrPublished,
2046
2051
  authenticated,
2047
- appearanceOptions,
2052
+ appearanceOptions2 as appearanceOptions,
2048
2053
  anyone,
2049
2054
  addCollectionsToSitemap,
2050
2055
  STATIC_PAGES_SLUG,
package/dist/test.js CHANGED
@@ -29,7 +29,6 @@ var authenticatedOrPublished = ({ req: { user } }) => {
29
29
  return true;
30
30
  return { _status: { equals: "published" } };
31
31
  };
32
-
33
32
  // src/render/_locale.ts
34
33
  function prefixFor(locale, defaultLocale, mode) {
35
34
  if (mode === "never")
@@ -201,24 +200,9 @@ var createPagesCollection = (blocks, options = {}) => {
201
200
  renderPath = PAGES_RENDER_PATH,
202
201
  slug: collectionSlug = PAGES_SLUG2,
203
202
  localePrefix,
204
- defaultLocale
203
+ defaultLocale,
204
+ nested = false
205
205
  } = options;
206
- const slugField = {
207
- name: "slug",
208
- type: "text",
209
- required: true,
210
- unique: true,
211
- index: true,
212
- admin: { position: "sidebar" },
213
- validate: (value) => {
214
- if (typeof value !== "string")
215
- return "Slug must be a string";
216
- if (value !== "" && !/^[a-z0-9-]+$/.test(value)) {
217
- return "Slug must be lowercase, with hyphens (no spaces or special characters)";
218
- }
219
- return true;
220
- }
221
- };
222
206
  const baseFields = [
223
207
  {
224
208
  name: "title",
@@ -248,7 +232,7 @@ var createPagesCollection = (blocks, options = {}) => {
248
232
  type: "date",
249
233
  admin: { position: "sidebar" }
250
234
  },
251
- slugField
235
+ slugField({ nested })
252
236
  ];
253
237
  const { afterChange: revalidateAfterChange, afterDelete: revalidateAfterDelete } = createRevalidateCollectionHook({
254
238
  collectionSlug,
@@ -283,14 +267,6 @@ var createPostsCollection = (options = {}) => {
283
267
  localePrefix,
284
268
  defaultLocale
285
269
  } = options;
286
- const slugField = {
287
- name: "slug",
288
- type: "text",
289
- required: true,
290
- unique: true,
291
- index: true,
292
- admin: { position: "sidebar" }
293
- };
294
270
  const baseFields = [
295
271
  {
296
272
  name: "title",
@@ -315,7 +291,7 @@ var createPostsCollection = (options = {}) => {
315
291
  type: "date",
316
292
  admin: { position: "sidebar" }
317
293
  },
318
- slugField
294
+ slugField()
319
295
  ];
320
296
  const { afterChange, afterDelete } = createRevalidateCollectionHook({
321
297
  collectionSlug,
@@ -416,17 +392,18 @@ var createStaticPagesCollection = (blocks) => {
416
392
  };
417
393
 
418
394
  // src/core/fields/link.ts
419
- var appearanceOptions = {
395
+ var appearanceOptions2 = {
420
396
  default: { label: "Default", value: "default" },
421
397
  outline: { label: "Outline", value: "outline" }
422
398
  };
423
- var link = (options = {}) => {
399
+ var link2 = (options = {}) => {
424
400
  const {
425
401
  appearances,
426
402
  disableLabel = false,
427
403
  relationTo = [PAGES_SLUG],
428
404
  localized = false,
429
- overrides = {}
405
+ overrides = {},
406
+ extraFields = []
430
407
  } = options;
431
408
  const result = {
432
409
  name: "link",
@@ -494,7 +471,7 @@ var link = (options = {}) => {
494
471
  result.fields = [...result.fields, ...linkTypes];
495
472
  }
496
473
  if (appearances !== false) {
497
- const opts = appearances ? appearances.map((a) => appearanceOptions[a]) : [appearanceOptions.default, appearanceOptions.outline];
474
+ const opts = appearances ? appearances.map((a) => appearanceOptions2[a]) : [appearanceOptions2.default, appearanceOptions2.outline];
498
475
  result.fields.push({
499
476
  name: "appearance",
500
477
  type: "select",
@@ -503,6 +480,9 @@ var link = (options = {}) => {
503
480
  options: opts
504
481
  });
505
482
  }
483
+ if (extraFields.length) {
484
+ result.fields.push(...extraFields);
485
+ }
506
486
  return { ...result, ...overrides };
507
487
  };
508
488
 
@@ -522,17 +502,22 @@ function createRevalidateGlobalHook(slug) {
522
502
 
523
503
  // src/data/collections/globals/Header/config.ts
524
504
  var createHeaderGlobal = (options = {}) => {
525
- const { renderPath = HEADER_RENDER_PATH, linkRelationTo = [PAGES_SLUG] } = options;
505
+ const {
506
+ renderPath = HEADER_RENDER_PATH,
507
+ linkRelationTo = [PAGES_SLUG],
508
+ navColumnLinkFields = [],
509
+ navItemLinkFields = []
510
+ } = options;
526
511
  const navColumnBlock = {
527
512
  slug: "navColumn",
528
513
  fields: [
529
514
  { name: "title", type: "text", required: true, localized: true },
530
- { name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })] }
515
+ { name: "links", type: "array", fields: [link2({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
531
516
  ]
532
517
  };
533
518
  const navItemBlock = {
534
519
  slug: "navItem",
535
- fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })]
520
+ fields: [link2({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
536
521
  };
537
522
  return {
538
523
  slug: "header",
@@ -554,17 +539,22 @@ var createHeaderGlobal = (options = {}) => {
554
539
 
555
540
  // src/data/collections/globals/Footer/config.ts
556
541
  var createFooterGlobal = (options = {}) => {
557
- const { renderPath = FOOTER_RENDER_PATH, linkRelationTo = [PAGES_SLUG] } = options;
542
+ const {
543
+ renderPath = FOOTER_RENDER_PATH,
544
+ linkRelationTo = [PAGES_SLUG],
545
+ navColumnLinkFields = [],
546
+ navItemLinkFields = []
547
+ } = options;
558
548
  const navColumnBlock = {
559
549
  slug: "navColumn",
560
550
  fields: [
561
551
  { name: "title", type: "text", required: true, localized: true },
562
- { name: "links", type: "array", fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })] }
552
+ { name: "links", type: "array", fields: [link2({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navColumnLinkFields })] }
563
553
  ]
564
554
  };
565
555
  const navItemBlock = {
566
556
  slug: "navItem",
567
- fields: [link({ appearances: false, localized: true, relationTo: linkRelationTo })]
557
+ fields: [link2({ appearances: false, localized: true, relationTo: linkRelationTo, extraFields: navItemLinkFields })]
568
558
  };
569
559
  return {
570
560
  slug: "footer",
@@ -653,7 +643,7 @@ function getFromImportMap(key, importMap) {
653
643
  var queryDocBySlug = cache(async function queryDocBySlug2({
654
644
  collectionSlug,
655
645
  slug,
656
- slugField = "slug",
646
+ slugField: slugField2 = "slug",
657
647
  locale,
658
648
  draft = false,
659
649
  config
@@ -665,14 +655,14 @@ var queryDocBySlug = cache(async function queryDocBySlug2({
665
655
  limit: 1,
666
656
  pagination: false,
667
657
  overrideAccess: draft,
668
- where: { [slugField]: { equals: slug } },
658
+ where: { [slugField2]: { equals: slug } },
669
659
  locale
670
660
  });
671
661
  return result.docs?.[0] ?? null;
672
662
  });
673
663
  var queryAllDocs = cache(async function queryAllDocs2({
674
664
  collectionSlug,
675
- slugField = "slug",
665
+ slugField: slugField2 = "slug",
676
666
  locale,
677
667
  config
678
668
  }) {
@@ -683,7 +673,7 @@ var queryAllDocs = cache(async function queryAllDocs2({
683
673
  limit: 1000,
684
674
  pagination: false,
685
675
  overrideAccess: false,
686
- select: { [slugField]: true },
676
+ select: { [slugField2]: true },
687
677
  locale
688
678
  });
689
679
  return result.docs ?? [];
@@ -691,7 +681,7 @@ var queryAllDocs = cache(async function queryAllDocs2({
691
681
  var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
692
682
  collectionSlug,
693
683
  slug,
694
- slugField = "slug",
684
+ slugField: slugField2 = "slug",
695
685
  locale,
696
686
  config
697
687
  }) {
@@ -703,13 +693,25 @@ var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
703
693
  pagination: false,
704
694
  overrideAccess: false,
705
695
  locale,
706
- where: { [slugField]: { equals: slug } },
707
- select: { [slugField]: true }
696
+ where: { [slugField2]: { equals: slug } },
697
+ select: { [slugField2]: true }
708
698
  });
709
699
  const doc = result.docs?.[0];
710
700
  if (!doc)
711
701
  return;
712
- const fieldValue = doc?.[slugField];
702
+ let fieldValue = doc[slugField2];
703
+ if (doc.id != null) {
704
+ const allLocales2 = await payload.findByID({
705
+ collection: collectionSlug,
706
+ id: doc.id,
707
+ locale: "all",
708
+ draft: false,
709
+ overrideAccess: false,
710
+ select: { [slugField2]: true }
711
+ }).catch(() => null);
712
+ if (allLocales2)
713
+ fieldValue = allLocales2[slugField2];
714
+ }
713
715
  if (fieldValue && typeof fieldValue === "object") {
714
716
  return fieldValue;
715
717
  }
@@ -762,6 +764,7 @@ function createSitemapFile(options) {
762
764
  const collectionDefaults = options.perCollection?.[collectionSlug] ?? {};
763
765
  const urlPrefix = (options.urlPrefixes?.[collectionSlug] ?? "").replace(/\/$/, "");
764
766
  const siteUrl = options.getServerSideURL().replace(/\/$/, "");
767
+ const isNested = options.nested?.[collectionSlug] ?? false;
765
768
  for (const locale of activeLocales) {
766
769
  const docs = await queryAllDocs({
767
770
  collectionSlug,
@@ -777,13 +780,14 @@ function createSitemapFile(options) {
777
780
  if (seen.has(dedupeKey))
778
781
  continue;
779
782
  seen.add(dedupeKey);
780
- const url = `${siteUrl}${prefixFor(locale, defaultLocale, options.localePrefix ?? "always")}${urlPrefix}/${storedSlug}`;
783
+ const slugPath = isNested ? storedSlug.replaceAll("_", "/") : storedSlug;
784
+ const url = `${siteUrl}${prefixFor(locale, defaultLocale, options.localePrefix ?? "always")}${urlPrefix}/${slugPath}`;
781
785
  const languages = await buildHreflangAlternates({
782
786
  siteUrl,
783
787
  locale,
784
788
  urlPrefix,
785
789
  storedSlug,
786
- nested: false,
790
+ nested: isNested,
787
791
  homeSlug: "",
788
792
  defaultLocale,
789
793
  locales: activeLocales,
@@ -814,7 +818,7 @@ function createSitemapFile(options) {
814
818
  }
815
819
  // src/config/createWWWConfig.ts
816
820
  function createWWWConfig(options) {
817
- const { locales, routing, blocks, linkRelationTo, registerPosts = true, defaultPlugins } = options;
821
+ const { locales, routing, blocks, linkRelationTo, registerPosts = true, nested = false, defaultPlugins } = options;
818
822
  const defaultLocale = routing?.defaultLocale ?? locales[0] ?? "";
819
823
  const localePrefixMode = (() => {
820
824
  const raw = routing?.localePrefix;
@@ -827,7 +831,8 @@ function createWWWConfig(options) {
827
831
  }
828
832
  const buildPagesCollection = () => createPagesCollection(blocks, {
829
833
  localePrefix: localePrefixMode,
830
- defaultLocale
834
+ defaultLocale,
835
+ nested
831
836
  });
832
837
  const buildPostsCollection = () => createPostsCollection({
833
838
  localePrefix: localePrefixMode,
@@ -58,6 +58,14 @@ type WWWConfigOptions = {
58
58
  */
59
59
  registerPosts?: boolean;
60
60
  /**
61
+ * Enable nested (hierarchical) Pages slugs. When `true`, the lib's
62
+ * Pages collection accepts the `_` nesting divider in its slug
63
+ * (`about_us` → `/about/us`). Pass the same `nested: true` to
64
+ * `createCollectionPageExports` on the Pages route so URL building,
65
+ * hreflang, and static params expand the divider. Default: `false`.
66
+ */
67
+ nested?: boolean;
68
+ /**
61
69
  * Final say on the lib's default plugin list. Receives the
62
70
  * `[seoPlugin, imageHashPlugin, translator]` array; return the
63
71
  * list to apply. Common uses: drop the translator (no AI