import routesMap from "./routes-map.js";

const generateRouter = (routes) => {
    return routes.map(v => ({
        path: v.path,
        name: v.name,
        title: v.title,
        meta: v.meta,
        component: routesMap[v.component],
        children: v.children && v.children.length > 0 && [
            {path: '', redirect: `/home/${v.name}/${v.children[0].name}`},
            ...generateRouter(v.children)
        ],
    }))
}

export default generateRouter;
