vant/docs/src/router.config.js
cookfront eccbd2269c docs
2017-04-10 10:46:50 +08:00

40 lines
832 B
JavaScript

const registerRoute = (navConfig, isExample) => {
let route = [];
let navs = navConfig['zh-CN'];
navs.forEach(nav => {
if (isExample && !nav.showInMobile) {
return;
}
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) {
const component = isExample
? require(`../examples-dist${page.path}.vue`)
: require(`../examples-docs${page.path}.md`);
route.push({
path: '/component' + page.path,
component: component.default || component
});
}
// console.log(route);
return route;
};
export default registerRoute;