Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 21, 2024
1 parent 62b7061 commit 7fec893
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions packages/edit-site/src/components/layout/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,40 +34,23 @@ function useRedirectOldPaths() {
const history = useHistory();
const { params } = useLocation();
useEffect( () => {
const {
postType,
postId,
path,
layout,
isCustom,
canvas,
categoryType,
...rest
} = params;
const { postType, path, categoryType, ...rest } = params;

if ( path === '/wp_template_part/all' ) {
history.replace( { postType: TEMPLATE_PART_POST_TYPE } );
}

const allParamsButPath = {
postId,
layout,
isCustom,
canvas,
...rest,
};

if ( path === '/page' ) {
history.replace( {
postType: 'page',
...allParamsButPath,
...rest,
} );
}

if ( path === '/wp_template' ) {
history.replace( {
postType: TEMPLATE_POST_TYPE,
...allParamsButPath,
...rest,
} );
}

Expand All @@ -77,14 +60,14 @@ function useRedirectOldPaths() {
categoryType === TEMPLATE_PART_POST_TYPE
? TEMPLATE_PART_POST_TYPE
: PATTERN_TYPES.user,
...allParamsButPath,
...rest,
} );
}

if ( path === '/navigation' ) {
history.replace( {
postType: NAVIGATION_POST_TYPE,
...allParamsButPath,
...rest,
} );
}
}, [ history, params ] );
Expand Down

0 comments on commit 7fec893

Please sign in to comment.