mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
37 lines
730 B
JavaScript
37 lines
730 B
JavaScript
import navConfig from './nav.config.json';
|
|
|
|
const registerRoute = (navConfig) => {
|
|
let route = [];
|
|
let navs = navConfig['zh-CN'];
|
|
navs.forEach(nav => {
|
|
if (nav.groups) {
|
|
nav.groups.forEach(group => {
|
|
group.list.forEach(nav => {
|
|
addRoute(nav);
|
|
});
|
|
});
|
|
} else if (nav.children) {
|
|
nav.children.forEach(nav => {
|
|
addRoute(nav);
|
|
});
|
|
} else {
|
|
addRoute(nav);
|
|
}
|
|
});
|
|
|
|
function addRoute(page) {
|
|
route.push({
|
|
path: '/component' + page.path,
|
|
component: function(resolve) {
|
|
require([`./examples-docs${page.path}.md`], resolve);
|
|
}
|
|
});
|
|
}
|
|
|
|
return route;
|
|
};
|
|
|
|
let route = registerRoute(navConfig);
|
|
|
|
export default route;
|