ant-design/site/theme/index.js

85 lines
2.0 KiB
JavaScript
Raw Normal View History

2017-01-20 11:47:08 +08:00
const path = require('path');
const homeTmpl = './template/Home/index';
const contentTmpl = './template/Content/index';
2017-01-20 11:47:08 +08:00
function pickerGenerator(module) {
const tester = new RegExp(`^docs/${module}`);
return (markdownData) => {
2017-10-09 13:23:20 +08:00
const { filename } = markdownData.meta;
2017-01-20 11:47:08 +08:00
if (tester.test(filename) &&
!/\/demo$/.test(path.dirname(filename))) {
return {
meta: markdownData.meta,
};
}
};
}
2016-06-03 13:21:27 +08:00
module.exports = {
2017-01-20 11:47:08 +08:00
lazyLoad(nodePath, nodeValue) {
if (typeof nodeValue === 'string') {
return true;
}
return nodePath.endsWith('/demo');
2016-03-07 11:35:23 +08:00
},
2017-01-20 11:47:08 +08:00
pick: {
components(markdownData) {
2017-10-09 13:23:20 +08:00
const { filename } = markdownData.meta;
2017-01-20 11:47:08 +08:00
if (!/^components/.test(filename) ||
/[/\\]demo$/.test(path.dirname(filename))) return;
2017-01-20 11:47:08 +08:00
return {
meta: markdownData.meta,
};
},
changelog(markdownData) {
if (/CHANGELOG/.test(markdownData.meta.filename)) {
return {
meta: markdownData.meta,
};
}
},
'docs/pattern': pickerGenerator('pattern'),
'docs/react': pickerGenerator('react'),
'docs/resource': pickerGenerator('resource'),
'docs/spec': pickerGenerator('spec'),
2016-05-11 09:32:33 +08:00
},
2017-01-20 11:47:08 +08:00
plugins: [
'bisheng-plugin-description',
'bisheng-plugin-toc?maxDepth=2&keepElem',
'bisheng-plugin-antd',
'bisheng-plugin-react?lang=__react',
],
routes: {
2016-07-26 15:24:48 +08:00
path: '/',
component: './template/Layout/index',
indexRoute: { component: homeTmpl },
2016-07-26 15:24:48 +08:00
childRoutes: [{
path: 'index-cn',
component: homeTmpl,
2016-07-26 15:24:48 +08:00
}, {
2016-07-26 17:40:08 +08:00
path: 'docs/pattern/:children',
2016-07-26 15:24:48 +08:00
component: contentTmpl,
}, {
2016-07-26 17:40:08 +08:00
path: 'docs/react/:children',
2016-07-26 15:24:48 +08:00
component: contentTmpl,
}, {
2016-07-26 17:40:08 +08:00
path: 'changelog',
2016-07-26 15:24:48 +08:00
component: contentTmpl,
}, {
path: 'changelog-cn',
component: contentTmpl,
2016-07-26 15:24:48 +08:00
}, {
2016-08-03 15:41:18 +08:00
path: 'components/:children/',
2016-07-26 15:24:48 +08:00
component: contentTmpl,
}, {
2016-07-26 17:40:08 +08:00
path: 'docs/spec/:children',
2016-07-26 15:24:48 +08:00
component: contentTmpl,
}, {
2016-07-26 17:40:08 +08:00
path: 'docs/resource/:children',
2016-07-26 15:24:48 +08:00
component: contentTmpl,
}],
},
2016-03-07 11:35:23 +08:00
};