element/examples/route.config.js
2016-07-27 17:05:28 +08:00

37 lines
774 B
JavaScript

import navConfig from './nav.config.json';
const registerRoute = (config) => {
let route = [];
config
.map(nav =>
nav.list.map(page => {
if (page.path === '/changelog') return;
const component = require(`./docs${page.path}.md`);
route.push({
path: page.path,
title: page.title || page.name,
description: page.description,
component: component.default || component
});
})
);
return { route, navs: config };
};
const route = registerRoute(navConfig);
route.route.push({
path: '/changelog',
component: require('../CHANGELOG.md')
});
route.route.push({
path: '*',
component: require('./docs/home.md')
});
export const navs = route.navs;
export default route.route;