site: upgrade bisheng

This commit is contained in:
Benjy Cui 2016-07-26 15:24:48 +08:00
parent fec500698e
commit 6cac87fa17
6 changed files with 50 additions and 42 deletions

View File

@ -78,7 +78,7 @@
"babel-eslint": "^6.0.2", "babel-eslint": "^6.0.2",
"babel-jest": "^13.2.2", "babel-jest": "^13.2.2",
"babel-plugin-antd": "^0.4.0", "babel-plugin-antd": "^0.4.0",
"bisheng": "^0.7.1", "bisheng": "^0.9.0",
"bisheng-plugin-antd": "~0.2.0", "bisheng-plugin-antd": "~0.2.0",
"bisheng-plugin-description": "^0.1.1", "bisheng-plugin-description": "^0.1.1",
"bisheng-plugin-react": "^0.2.0", "bisheng-plugin-react": "^0.2.0",

View File

@ -21,13 +21,30 @@ module.exports = {
'0.12.x': 'http://012x.ant.design/', '0.12.x': 'http://012x.ant.design/',
}, },
routes: { routes: {
'/': './template/Home/index', path: '/',
'/docs/practice/:children': contentTmpl, component: './template/Layout/index',
'/docs/pattern/:children': contentTmpl, indexRoute: { component: './template/Home/index' },
'/docs/react/:children': contentTmpl, childRoutes: [{
'/changelog': contentTmpl, path: '/docs/practice/:children',
'/components/:children': contentTmpl, component: contentTmpl,
'/docs/spec/:children': contentTmpl, }, {
'/docs/resource/:children': contentTmpl, path: '/docs/pattern/:children',
component: contentTmpl,
}, {
path: '/docs/react/:children',
component: contentTmpl,
}, {
path: '/changelog',
component: contentTmpl,
}, {
path: '/components/:children',
component: contentTmpl,
}, {
path: '/docs/spec/:children',
component: contentTmpl,
}, {
path: '/docs/resource/:children',
component: contentTmpl,
}],
}, },
}; };

View File

@ -1,5 +1,4 @@
import React from 'react'; import React from 'react';
import Layout from '../Layout';
import MainContent from './MainContent'; import MainContent from './MainContent';
import Promise from 'bluebird'; import Promise from 'bluebird';
import * as utils from '../utils'; import * as utils from '../utils';
@ -41,9 +40,5 @@ export function collect(nextProps, callback) {
} }
export default (props) => { export default (props) => {
return ( return <MainContent {...props} />;
<Layout {...props}>
<MainContent {...props} />
</Layout>
);
}; };

View File

@ -1,20 +1,11 @@
import React from 'react'; import React from 'react';
import DocumentTitle from 'react-document-title'; import DocumentTitle from 'react-document-title';
import Layout from '../Layout';
import Link from './Link'; import Link from './Link';
import Banner from './Banner'; import Banner from './Banner';
import Page1 from './Page1'; import Page1 from './Page1';
import Page2 from './Page2'; import Page2 from './Page2';
import Page3 from './Page3'; import Page3 from './Page3';
import Page4 from './Page4'; import Page4 from './Page4';
import Promise from 'bluebird';
import * as utils from '../utils';
export function collect(nextProps, callback) {
const componentsList = utils.collectDocs(nextProps.data.components);
Promise.all(componentsList)
.then((list) => callback(null, { ...nextProps, components: list }));
}
export default class Home extends React.Component { export default class Home extends React.Component {
// To store style which is only for Home and has conflicts with others. // To store style which is only for Home and has conflicts with others.
@ -96,17 +87,15 @@ export default class Home extends React.Component {
render() { render() {
return ( return (
<DocumentTitle title="Ant Design - 一个 UI 设计语言"> <DocumentTitle title="Ant Design - 一个 UI 设计语言">
<Layout {...this.props}> <div className="main-wrapper">
<div className="main-wrapper"> <Link />
<Link /> <Banner />
<Banner /> <Page1 />
<Page1 /> <Page2 />
<Page2 /> <Page3 />
<Page3 /> <Page4 />
<Page4 /> <style dangerouslySetInnerHTML={{ __html: this.getStyle() }} />
<style dangerouslySetInnerHTML={{ __html: this.getStyle() }} /> </div>
</div>
</Layout>
</DocumentTitle> </DocumentTitle>
); );
} }

View File

@ -89,10 +89,10 @@ export default class Header extends React.Component {
} }
render() { render() {
const { routes, components } = this.props; const { location, components } = this.props;
const route = routes[0].path.replace(/^\//, ''); const module = location.pathname.split('/').slice(0, -1).join('/');
let activeMenuItem = route.slice(0, route.indexOf(':') - 1) || 'home'; let activeMenuItem = module || 'home';
if (activeMenuItem === 'components' || route === 'changelog') { if (activeMenuItem === 'components' || location.pathname === 'changelog') {
activeMenuItem = 'docs/react'; activeMenuItem = 'docs/react';
} }
@ -144,7 +144,7 @@ export default class Header extends React.Component {
</Select> </Select>
</div> </div>
{ {
location.port ? ( window.location.port ? (
<Button id="lang" type="ghost" size="small" onClick={this.handleLangChange}> <Button id="lang" type="ghost" size="small" onClick={this.handleLangChange}>
<FormattedMessage id="app.header.lang" /> <FormattedMessage id="app.header.lang" />
</Button> </Button>

View File

@ -1,9 +1,10 @@
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import * as antd from '../../../../index';
import { addLocaleData, IntlProvider } from 'react-intl'; import { addLocaleData, IntlProvider } from 'react-intl';
import Promise from 'bluebird';
import Header from './Header'; import Header from './Header';
import Footer from './Footer'; import Footer from './Footer';
import * as utils from '../utils';
import enLocale from '../../en-US.js'; import enLocale from '../../en-US.js';
import cnLocale from '../../zh-CN.js'; import cnLocale from '../../zh-CN.js';
import '../../static/style'; import '../../static/style';
@ -11,7 +12,7 @@ import '../../static/style';
// Expose to iframe // Expose to iframe
window.react = React; window.react = React;
window['react-dom'] = ReactDOM; window['react-dom'] = ReactDOM;
window.antd = antd; window.antd = require('antd');
// Polyfill // Polyfill
const areIntlLocalesSupported = require('intl-locales-supported'); const areIntlLocalesSupported = require('intl-locales-supported');
@ -42,6 +43,12 @@ const isZhCN = (typeof localStorage !== 'undefined' && localStorage.getItem('loc
const appLocale = isZhCN ? cnLocale : enLocale; const appLocale = isZhCN ? cnLocale : enLocale;
addLocaleData(appLocale.data); addLocaleData(appLocale.data);
export function collect(nextProps, callback) {
const componentsList = utils.collectDocs(nextProps.data.components);
Promise.all(componentsList)
.then((list) => callback(null, { ...nextProps, components: list }));
}
let gaListenerSetted = false; let gaListenerSetted = false;
export default class Layout extends React.Component { export default class Layout extends React.Component {
static contextTypes = { static contextTypes = {