ant-design/site/theme/index.js
Bo Chen f0adb4dc5f site: run ant-design on windows #4725
* 5hours's work

* 过年好!!

* lint issue
2017-01-26 16:51:06 +08:00

92 lines
2.2 KiB
JavaScript

const path = require('path');
const homeTmpl = './template/Home/index';
const contentTmpl = './template/Content/index';
function pickerGenerator(module) {
const tester = new RegExp(`^docs/${module}`);
return (markdownData) => {
const filename = markdownData.meta.filename;
if (tester.test(filename) &&
!/\/demo$/.test(path.dirname(filename))) {
return {
meta: markdownData.meta,
};
}
};
}
module.exports = {
lazyLoad(nodePath, nodeValue) {
if (typeof nodeValue === 'string') {
return true;
}
return nodePath.endsWith('/demo');
},
pick: {
components(markdownData) {
const filename = markdownData.meta.filename;
if (!/^components/.test(filename) ||
/[/\\]demo$/.test(path.dirname(filename))) return;
return {
meta: markdownData.meta,
};
},
changelog(markdownData) {
if (/CHANGELOG/.test(markdownData.meta.filename)) {
return {
meta: markdownData.meta,
};
}
},
'docs/pattern': pickerGenerator('pattern'),
'docs/practice': pickerGenerator('practice'),
'docs/react': pickerGenerator('react'),
'docs/resource': pickerGenerator('resource'),
'docs/spec': pickerGenerator('spec'),
},
plugins: [
'bisheng-plugin-description',
'bisheng-plugin-toc?maxDepth=2&keepElem',
'bisheng-plugin-antd',
'bisheng-plugin-react?lang=__react',
],
routes: {
path: '/',
component: './template/Layout/index',
indexRoute: { component: homeTmpl },
childRoutes: [{
path: 'index-cn',
component: homeTmpl,
dataPath: '/',
}, {
path: 'docs/practice/:children',
component: contentTmpl,
}, {
path: 'docs/pattern/:children',
component: contentTmpl,
}, {
path: 'docs/react/:children',
component: contentTmpl,
}, {
path: 'changelog',
component: contentTmpl,
dataPath: 'CHANGELOG',
}, {
path: 'changelog-cn',
component: contentTmpl,
dataPath: 'CHANGELOG',
}, {
path: 'components/:children/',
component: contentTmpl,
}, {
path: 'docs/spec/:children',
component: contentTmpl,
}, {
path: 'docs/resource/:children',
component: contentTmpl,
}],
},
};