Skip to content

Commit

Permalink
This commit:
Browse files Browse the repository at this point in the history
- links the posts page to the homepage template when a post page is set
- abstracts logic to get page item props
  • Loading branch information
ramonjd committed Jul 6, 2023
1 parent f6efbc2 commit 4e499df
Showing 1 changed file with 34 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,26 @@ export default function SidebarNavigationScreenPages() {
setShowAddPage( false );
};

const getPageProps = ( id ) => {
let itemIcon = page;
const isPostsPage = postsPage && postsPage === id;

switch ( id ) {
case frontPage:
itemIcon = home;
break;
case postsPage:
itemIcon = verse;
break;
}

return {
icon: itemIcon,
postType: isPostsPage ? 'wp_template' : 'page',
postId: isPostsPage ? homeTemplate.id : id,
};
};

return (
<>
{ showAddPage && (
Expand Down Expand Up @@ -152,34 +172,20 @@ export default function SidebarNavigationScreenPages() {
</Truncate>
</PageItem>
) }
{ reorderedPages?.map( ( item ) => {
let itemIcon;
switch ( item.id ) {
case frontPage:
itemIcon = home;
break;
case postsPage:
itemIcon = verse;
break;
default:
itemIcon = page;
}
return (
<PageItem
postId={ item.id }
key={ item.id }
icon={ itemIcon }
withChevron
>
<Truncate numberOfLines={ 1 }>
{ decodeEntities(
item?.title?.rendered ||
__( '(no title)' )
) }
</Truncate>
</PageItem>
);
} ) }
{ reorderedPages?.map( ( { id, title } ) => (
<PageItem
{ ...getPageProps( id ) }
key={ id }
withChevron
>
<Truncate numberOfLines={ 1 }>
{ decodeEntities(
title?.rendered ||
__( '(no title)' )
) }
</Truncate>
</PageItem>
) ) }
</ItemGroup>
) }
</>
Expand Down

0 comments on commit 4e499df

Please sign in to comment.