import React from "react" ; import { plugins } from "@webiny/plugins" ; import { Switch } from "@webiny/react-router" ; import { RoutePlugin } from "../types" ; export const Routes = ( ) => { const routes = [ ... plugins . byType < RoutePlugin > ( "route" ) ] . sort ( ( a , b ) => { const pathA = a . route . props . path || "*" ; const pathB = b . route . props . path || "*" ; if ( pathA === "/" && pathB === "*" ) { return - 1 ; } if ( pathA === "*" || pathA === "/" ) { return 1 ; } if ( [ "*" , "/" ] . includes ( pathB ) ) { return - 1 ; } return 0 ; } ) ; return ( < Switch > { routes . map ( ( { route , name } ) => React . cloneElement ( route , { key : name } ) ) } < /Switch>); } ;