import config from '@ldesign/mobile-vue/site.config'; import Home from '../components/home.vue'; const { docs } = config; function getDocsRoutes(docs: any[], type?: string) { let docsRoutes: any[] = []; docs.forEach((item) => { const docType = item.type || type; let { children } = item; if (docType === 'component') { children = item.children?.sort((a: any, b: any) => { const nameA = a.name.toUpperCase(); const nameB = b.name.toUpperCase(); if (nameA < nameB) return -1; if (nameA > nameB) return 1; return 0; }); } if (children) { docsRoutes = docsRoutes.concat(getDocsRoutes(children, docType)); } else { docsRoutes.push({ path: `/${item.name}`, name: item.name, meta: { title: item.title }, component: item.mobile, }); } }); return docsRoutes; } const routes = [ { path: '/', component: Home, }, ...getDocsRoutes(docs), ]; export default routes;