diff --git a/package.json b/package.json index f5cec8a230..c3b8291397 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/site/bisheng.config.js b/site/bisheng.config.js index 4a1919009e..fabdb50da6 100644 --- a/site/bisheng.config.js +++ b/site/bisheng.config.js @@ -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']; diff --git a/site/theme/index.js b/site/theme/index.js index dec3f24947..31d58e1ea5 100644 --- a/site/theme/index.js +++ b/site/theme/index.js @@ -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, - }, - 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', + 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', diff --git a/site/theme/template/Content/MainContent.jsx b/site/theme/template/Content/MainContent.jsx index f7960f8b5a..e5ace5075a 100644 --- a/site/theme/template/Content/MainContent.jsx +++ b/site/theme/template/Content/MainContent.jsx @@ -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 ( diff --git a/site/theme/template/Layout/Footer.jsx b/site/theme/template/Layout/Footer.jsx index ef3d9a5e3d..3427e197cc 100644 --- a/site/theme/template/Layout/Footer.jsx +++ b/site/theme/template/Layout/Footer.jsx @@ -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 => ); return ( diff --git a/site/theme/template/Layout/index.jsx b/site/theme/template/Layout/index.jsx index 9a34b9b877..162469e59f 100644 --- a/site/theme/template/Layout/index.jsx +++ b/site/theme/template/Layout/index.jsx @@ -70,7 +70,7 @@ export default class Layout extends React.Component {
{cloneElement(children, { onEnterChange: this.onEnterChange })} -