Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address feedback
  • Loading branch information
tellthemachines committed May 29, 2023
commit bb94a2235741a73ffabc48990da0bb08ef13d95c
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ export default function SidebarNavigationScreenPages() {
per_page: -1,
} );

const dynamicPageTemplates =
templates &&
templates.filter( ( template ) => {
return template.slug === '404' || template.slug === 'search';
} );
const dynamicPageTemplates = templates?.filter( ( { slug } ) =>
[ '404', 'search' ].includes( slug )
);

const homeTemplate =
templates?.find( ( template ) => template.slug === 'front-page' ) ||
Expand All @@ -69,20 +67,20 @@ export default function SidebarNavigationScreenPages() {

const isHomePageBlog = frontPage === postsPage;

if ( ! isHomePageBlog ) {
const homePageIndex = pages?.findIndex(
if ( ! isHomePageBlog && pages?.length ) {
const homePageIndex = pages.findIndex(
( item ) => item.id === frontPage
);
const homePage = pages?.splice( homePageIndex, 1 );
const homePage = pages.splice( homePageIndex, 1 );
pages?.splice( 0, 0, ...homePage );

const postsPageIndex = pages?.findIndex(
const postsPageIndex = pages.findIndex(
( item ) => item.id === postsPage
);

const blogPage = pages?.splice( postsPageIndex, 1 );
const blogPage = pages.splice( postsPageIndex, 1 );

pages?.splice( 1, 0, ...blogPage );
pages.splice( 1, 0, ...blogPage );
}

return (
Expand Down