Browse Source

site: improve performance

pull/2621/head
Benjy Cui 8 years ago
parent
commit
7c7a365960
  1. 2
      package.json
  2. 12
      site/bisheng.config.js
  3. 3
      site/theme/template/Layout/Header.jsx
  4. 8
      site/theme/template/Layout/index.jsx

2
package.json

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

12
site/bisheng.config.js

@ -13,6 +13,18 @@ module.exports = {
}
return nodePath.endsWith('/demo');
},
pick: {
components(markdownData) {
const filename = markdownData.meta.filename;
if (!/^components/.test(filename) ||
/\/demo$/.test(path.dirname(filename)) ||
/\.en-US\.md/.test(filename)) return;
return {
meta: markdownData.meta,
};
},
},
theme: './site/theme',
htmlTemplate: './site/theme/static/template.html',
plugins: [

3
site/theme/template/Layout/Header.jsx

@ -89,7 +89,8 @@ export default class Header extends React.Component {
}
render() {
const { location, components } = this.props;
const { location, picked } = this.props;
const components = picked.components;
const module = location.pathname.replace(/\/$/, '')
.split('/').slice(0, -1)
.join('/');

8
site/theme/template/Layout/index.jsx

@ -1,10 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { addLocaleData, IntlProvider } from 'react-intl';
import Promise from 'bluebird';
import Header from './Header';
import Footer from './Footer';
import * as utils from '../utils';
import enLocale from '../../en-US.js';
import cnLocale from '../../zh-CN.js';
import '../../static/style';
@ -42,12 +40,6 @@ const isZhCN = (typeof localStorage !== 'undefined' && localStorage.getItem('loc
const appLocale = isZhCN ? cnLocale : enLocale;
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 }));
}
export default class Layout extends React.Component {
static contextTypes = {
router: React.PropTypes.object.isRequired,

Loading…
Cancel
Save