Skip to content

Commit

Permalink
Splitting the Pr
Browse files Browse the repository at this point in the history
  • Loading branch information
benazeer-ben committed Feb 10, 2025
1 parent b12ef1c commit 0d4ebc7
Showing 1 changed file with 0 additions and 50 deletions.
50 changes: 0 additions & 50 deletions packages/block-library/src/page-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,55 +466,5 @@ export const transforms = {
);
},
},
{
type: 'block',
blocks: [ 'core/list' ],
transform: () => {
const pages = select( coreStore ).getEntityRecords(
'postType',
'page',
{
per_page: -1,
status: 'publish',
}
);

if ( ! pages || pages.length === 0 ) {
return createBlock( 'core/list', {
ordered: false,
} );
}

const createListItems = ( parentId = 0 ) => {
return pages
.filter( ( page ) => page.parent === parentId )
.map( ( page ) => {
const childItems = createListItems( page.id );
const listItem = createBlock( 'core/list-item', {
content: `<a href="${ page.link }">${ page.title.rendered }</a>`,
} );
if ( childItems.length > 0 ) {
const subList = createBlock(
'core/list',
{},
childItems
);
listItem.innerBlocks = [ subList ];
}
return listItem;
} );
};

const innerBlocks = createListItems();

return createBlock(
'core/list',
{
ordered: false,
},
innerBlocks
);
},
},
],
};

0 comments on commit 0d4ebc7

Please sign in to comment.