site: upgrade bisheng to 0.20.0

This commit is contained in:
Benjy Cui 2017-01-20 11:47:08 +08:00
parent 2004c13653
commit eb254572b7
6 changed files with 81 additions and 77 deletions

View File

@ -86,7 +86,7 @@
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"bisheng": "^0.19.0",
"bisheng": "^0.20.0",
"bisheng-plugin-antd": "^0.8.0",
"bisheng-plugin-description": "^0.1.1",
"bisheng-plugin-react": "^0.4.0",

View File

@ -1,18 +1,5 @@
const path = require('path');
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 = {
port: 8001,
source: [
@ -21,43 +8,33 @@ module.exports = {
'CHANGELOG.zh-CN.md', // TODO: fix it in bisheng
'CHANGELOG.en-US.md',
],
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'),
},
theme: './site/theme',
htmlTemplate: './site/theme/static/template.html',
plugins: [
'bisheng-plugin-description',
'bisheng-plugin-toc?maxDepth=2&keepElem',
'bisheng-plugin-antd',
'bisheng-plugin-react?lang=__react',
],
themeConfig: {
categoryOrder: {
十大原则: 0,
Principles: 0,
设计基础: 1,
'Design Fundamental': 1,
},
typeOrder: {
General: 0,
Layout: 1,
Navigation: 2,
'Data Entry': 3,
'Data Display': 4,
Feedback: 5,
Localization: 6,
Other: 7,
},
docVersions: {
'0.9.x': 'http://09x.ant.design',
'0.10.x': 'http://010x.ant.design',
'0.11.x': 'http://011x.ant.design',
'0.12.x': 'http://012x.ant.design',
'1.x': 'http://1x.ant.design',
},
},
filePathMapper(filePath) {
if (filePath === '/index.html') {
return ['/index.html', '/index-cn.html'];

View File

@ -1,30 +1,57 @@
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 = {
categoryOrder: {
十大原则: 0,
Principles: 0,
设计基础: 1,
'Design Fundamental': 1,
lazyLoad(nodePath, nodeValue) {
if (typeof nodeValue === 'string') {
return true;
}
return nodePath.endsWith('/demo');
},
typeOrder: {
General: 0,
Layout: 1,
Navigation: 2,
'Data Entry': 3,
'Data Display': 4,
Feedback: 5,
Localization: 6,
Other: 7,
pick: {
components(markdownData) {
const filename = markdownData.meta.filename;
if (!/^components/.test(filename) ||
/\/demo$/.test(path.dirname(filename))) return;
return {
meta: markdownData.meta,
};
},
docVersions: {
'0.9.x': 'http://09x.ant.design',
'0.10.x': 'http://010x.ant.design',
'0.11.x': 'http://011x.ant.design',
'0.12.x': 'http://012x.ant.design',
'1.x': 'http://1x.ant.design',
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',

View File

@ -4,7 +4,6 @@ import { Row, Col, Menu } from 'antd';
import Article from './Article';
import ComponentDoc from './ComponentDoc';
import * as utils from '../utils';
import config from '../../';
const SubMenu = Menu.SubMenu;
@ -124,9 +123,10 @@ export default class MainContent extends React.Component {
}
generateSubMenuItems(obj) {
const { themeConfig } = this.props;
const topLevel = (obj.topLevel || []).map(this.generateMenuItem.bind(this, true));
const itemGroups = Object.keys(obj).filter(isNotTopLevel)
.sort((a, b) => config.typeOrder[a] - config.typeOrder[b])
.sort((a, b) => themeConfig.typeOrder[a] - themeConfig.typeOrder[b])
.map((type) => {
const groupItems = obj[type].sort((a, b) => {
return a.title.charCodeAt(0) -
@ -142,13 +142,14 @@ export default class MainContent extends React.Component {
}
getMenuItems() {
const { themeConfig } = this.props;
const moduleData = getModuleData(this.props);
const menuItems = utils.getMenuItems(
moduleData, this.context.intl.locale
);
const topLevel = this.generateSubMenuItems(menuItems.topLevel);
const subMenu = Object.keys(menuItems).filter(isNotTopLevel)
.sort((a, b) => config.categoryOrder[a] - config.categoryOrder[b])
.sort((a, b) => themeConfig.categoryOrder[a] - themeConfig.categoryOrder[b])
.map((category) => {
const subMenuItems = this.generateSubMenuItems(menuItems[category]);
return (

View File

@ -3,7 +3,6 @@ import { FormattedMessage, injectIntl } from 'react-intl';
import { Select, Modal } from 'antd';
import { version as antdVersion } from 'antd/package.json';
import * as utils from '../utils';
import { docVersions } from '../../';
const Option = Select.Option;
@ -19,8 +18,6 @@ function isLocalStorageNameSupported() {
}
}
docVersions[antdVersion] = antdVersion;
class Footer extends React.Component {
componentDidMount() {
// for some iOS
@ -71,6 +68,8 @@ class Footer extends React.Component {
}
render() {
const { themeConfig } = this.props;
const docVersions = { ...themeConfig.docVersions, [antdVersion]: antdVersion };
const options = Object.keys(docVersions)
.map(version => <Option value={docVersions[version]} key={version}>{version}</Option>);
return (

View File

@ -70,7 +70,7 @@ export default class Layout extends React.Component {
<div className="page-wrapper">
<Header {...restProps} isFirstScreen={isFirstScreen} />
{cloneElement(children, { onEnterChange: this.onEnterChange })}
<Footer />
<Footer {...restProps} />
</div>
</LocaleProvider>
</IntlProvider>