ant-design/site/theme/index.js

100 lines
2.4 KiB
JavaScript
Raw Normal View History

2018-11-28 17:58:46 +08:00
require('core-js/es6/string');
const path = require('path');
2017-01-20 11:47:08 +08:00
const homeTmpl = './template/Home/index';
const contentTmpl = './template/Content/index';
2018-01-08 16:55:08 +08:00
const redirectTmpl = './template/Redirect';
const appShellTmpl = './template/AppShell';
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;
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;
if (!/^components/.test(filename)
2018-11-28 15:00:03 +08:00
|| /[/\\]demo$/.test(path.dirname(filename))) {
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/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: 'app-shell',
component: appShellTmpl,
}, {
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',
2018-01-08 16:55:08 +08:00
component: redirectTmpl,
2016-07-26 15:24:48 +08:00
}, {
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,
2018-01-08 16:55:08 +08:00
}, {
path: 'docs/spec/feature',
component: redirectTmpl,
}, {
path: 'docs/spec/feature-cn',
component: redirectTmpl,
2016-07-26 15:24:48 +08:00
}, {
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',
2018-01-08 16:55:08 +08:00
component: redirectTmpl,
2016-07-26 15:24:48 +08:00
}],
},
2016-03-07 11:35:23 +08:00
};