@@ -497,6 +497,7 @@ export async function POST(
497497 localeCode,
498498 collectionLayerClasses,
499499 collectionLayerTag,
500+ published : isPublished = true ,
500501 } = body ;
501502
502503 if ( ! layerTemplate || ! Array . isArray ( layerTemplate ) ) {
@@ -508,7 +509,7 @@ export async function POST(
508509
509510 const { matchingIds, total : filteredTotal } = await getFilteredItemIds (
510511 collectionId ,
511- true ,
512+ isPublished ,
512513 filterGroups ,
513514 ) ;
514515
@@ -525,7 +526,7 @@ export async function POST(
525526
526527 if ( ! sortBy || sortBy === 'none' || sortBy === 'manual' ) {
527528 // Let DB do ordering and pagination for cheap paths.
528- const { items } = await getItemsByCollectionId ( collectionId , true , {
529+ const { items } = await getItemsByCollectionId ( collectionId , isPublished , {
529530 itemIds : matchingIds ,
530531 limit : pageLimit ,
531532 offset : pageOffset ,
@@ -536,15 +537,15 @@ export async function POST(
536537 const randomizedIds = [ ...matchingIds ] . sort ( ( ) => Math . random ( ) - 0.5 ) ;
537538 pageItemIds = randomizedIds . slice ( pageOffset , pageOffset + pageLimit ) ;
538539 if ( pageItemIds . length > 0 ) {
539- const { items } = await getItemsByCollectionId ( collectionId , true , {
540+ const { items } = await getItemsByCollectionId ( collectionId , isPublished , {
540541 itemIds : pageItemIds ,
541542 } ) ;
542543 pageRawItems = reorderItemsById ( items , pageItemIds ) ;
543544 }
544545 } else {
545546 // For field-based sort, sort IDs using just the sort field values first,
546547 // then hydrate only the requested page window.
547- const sortValueByItem = await getFieldValuesForItems ( sortBy , true , matchingIds ) ;
548+ const sortValueByItem = await getFieldValuesForItems ( sortBy , isPublished , matchingIds ) ;
548549 const sortedIds = [ ...matchingIds ] . sort ( ( a , b ) => {
549550 const aStr = String ( sortValueByItem . get ( a ) || '' ) ;
550551 const bStr = String ( sortValueByItem . get ( b ) || '' ) ;
@@ -559,7 +560,7 @@ export async function POST(
559560 } ) ;
560561 pageItemIds = sortedIds . slice ( pageOffset , pageOffset + pageLimit ) ;
561562 if ( pageItemIds . length > 0 ) {
562- const { items } = await getItemsByCollectionId ( collectionId , true , {
563+ const { items } = await getItemsByCollectionId ( collectionId , isPublished , {
563564 itemIds : pageItemIds ,
564565 } ) ;
565566 pageRawItems = reorderItemsById ( items , pageItemIds ) ;
@@ -568,15 +569,15 @@ export async function POST(
568569
569570 const valuesByItem = await getValuesByItemIds (
570571 pageRawItems . map ( i => i . id ) ,
571- true ,
572+ isPublished ,
572573 ) ;
573574 const paginatedItems : CollectionItemWithValues [ ] = pageRawItems . map ( item => ( {
574575 ...item ,
575576 values : valuesByItem [ item . id ] || { } ,
576577 } ) ) ;
577578 const hasMore = pageOffset + paginatedItems . length < filteredTotal ;
578579
579- const collectionFields = await getFieldsByCollectionId ( collectionId , true , { excludeComputed : true } ) ;
580+ const collectionFields = await getFieldsByCollectionId ( collectionId , isPublished , { excludeComputed : true } ) ;
580581 const slugField = collectionFields . find ( f => f . key === 'slug' ) ;
581582 const collectionItemSlugs : Record < string , string > = { } ;
582583 if ( slugField ) {
@@ -595,7 +596,7 @@ export async function POST(
595596 let locale = null ;
596597 let translations : Record < string , any > | undefined ;
597598 if ( localeCode ) {
598- const localeData = await loadTranslationsForLocale ( localeCode , true ) ;
599+ const localeData = await loadTranslationsForLocale ( localeCode , isPublished ) ;
599600 locale = localeData . locale ;
600601 translations = localeData . translations ;
601602 }
@@ -605,7 +606,7 @@ export async function POST(
605606 layerTemplate as Layer [ ] ,
606607 collectionId ,
607608 collectionLayerId ,
608- true ,
609+ isPublished ,
609610 pages ,
610611 folders ,
611612 collectionItemSlugs ,
0 commit comments