ant-design/site/theme/index.js

98 lines
2.2 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';
const appShellTmpl = './template/AppShell';
2017-01-20 11:47:08 +08:00
function pickerGenerator(module) {
const tester = new RegExp(`^docs/${module}`);
2018-12-07 16:17:45 +08:00
return markdownData => {
2017-10-09 13:23:20 +08:00
const { filename } = markdownData.meta;
2018-12-07 16:17:45 +08:00
if (tester.test(filename) && !/\/demo$/.test(path.dirname(filename))) {
2017-01-20 11:47:08 +08:00
return {
meta: markdownData.meta,
};
}
2018-11-28 15:00:03 +08:00
return null;
2017-01-20 11:47:08 +08:00
};
}
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;
2018-12-07 16:17:45 +08:00
if (!/^components/.test(filename) || /[/\\]demo$/.test(path.dirname(filename))) {
2018-11-28 15:00:03 +08:00
return null;
}
2017-01-20 11:47:08 +08:00
return {
meta: markdownData.meta,
};
},
changelog(markdownData) {
if (/CHANGELOG/.test(markdownData.meta.filename)) {
return {
meta: markdownData.meta,
};
}
2018-11-28 15:00:03 +08:00
return null;
2017-01-20 11:47:08 +08:00
},
'docs/react': pickerGenerator('react'),
'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',
'@ant-design/bisheng-plugin?injectProvider',
2017-01-20 11:47:08 +08:00
'bisheng-plugin-react?lang=__react',
],
routes: {
2016-07-26 15:24:48 +08:00
path: '/',
component: './template/Layout/index',
indexRoute: { component: homeTmpl },
2018-12-07 16:17:45 +08:00
childRoutes: [
{
path: 'app-shell',
component: appShellTmpl,
},
{
path: 'index-cn',
component: homeTmpl,
},
{
path: 'docs/react/:children',
component: contentTmpl,
},
{
path: 'changelog',
component: contentTmpl,
},
{
path: 'changelog-cn',
component: contentTmpl,
},
{
path: 'components/form/v3',
component: contentTmpl,
},
{
path: 'components/form/v3-cn',
component: contentTmpl,
},
2018-12-07 16:17:45 +08:00
{
path: 'components/:children/',
component: contentTmpl,
},
{
path: 'docs/spec/:children',
component: contentTmpl,
},
],
},
2016-03-07 11:35:23 +08:00
};