mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 01:54:48 +00:00
load doc && demo in demand
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
const navs = require('./doc.config')['zh-CN'].nav;
|
||||
import componentDocs from '../examples-dist/entry-docs';
|
||||
import componentDemos from '../examples-dist/entry-demos';
|
||||
|
||||
const registerRoute = (isExample) => {
|
||||
let route = [];
|
||||
@@ -9,31 +11,26 @@ const registerRoute = (isExample) => {
|
||||
|
||||
if (nav.groups) {
|
||||
nav.groups.forEach(group => {
|
||||
group.list.forEach(nav => {
|
||||
addRoute(nav);
|
||||
});
|
||||
group.list.forEach(addRoute);
|
||||
});
|
||||
} else if (nav.children) {
|
||||
nav.children.forEach(nav => {
|
||||
addRoute(nav);
|
||||
});
|
||||
nav.children.forEach(addRoute);
|
||||
} 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
|
||||
});
|
||||
const { path } = page;
|
||||
if (path) {
|
||||
const name = path.replace('/', '');
|
||||
route.push({
|
||||
path: '/component' + path,
|
||||
component: isExample ? componentDemos[name] : componentDocs[name]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(route);
|
||||
|
||||
return route;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user