docs: update site

pull/77/merge
tjz 2018-07-14 17:10:50 +08:00
parent 0778cc098e
commit fdd9c3fda8
4 changed files with 22 additions and 26 deletions

View File

@ -1,6 +1,6 @@
<script> <script>
import { isZhCN } from '../util' import { isZhCN } from '../util'
import _ from 'lodash' import sortBy from 'lodash/sortBy'
export default { export default {
props: { props: {
name: String, name: String,
@ -27,7 +27,7 @@ export default {
}, },
render () { render () {
const name = this.name const name = this.name
const searchData = _.sortBy(this.searchData, ['title']) const searchData = sortBy(this.searchData, ['title'])
const isCN = isZhCN(name) const isCN = isZhCN(name)
return ( return (
<header id='header'> <header id='header'>

View File

@ -1,10 +1,9 @@
<script> <script>
import Vue from 'vue'
import AllDemo from '../demo' import AllDemo from '../demo'
import Header from './header' import Header from './header'
import zhCN from 'antd/locale-provider/zh_CN' import zhCN from 'antd/locale-provider/zh_CN'
import enUS from 'antd/locale-provider/default' import enUS from 'antd/locale-provider/default'
import _ from 'lodash' import sortBy from 'lodash/sortBy'
import { isZhCN } from '../util' import { isZhCN } from '../util'
import { Provider, create } from '../../components/_util/store' import { Provider, create } from '../../components/_util/store'
@ -78,24 +77,14 @@ export default {
const lis = [] const lis = []
currentSubMenu.forEach(({ cnTitle, usTitle, id }) => { currentSubMenu.forEach(({ cnTitle, usTitle, id }) => {
const title = isCN ? cnTitle : usTitle const title = isCN ? cnTitle : usTitle
const className = decodeURIComponent(window.location.hash) === `#${id}` ? 'current' : '' lis.push(<a-anchor-link href={`#${id}`} title={title} />)
lis.push(<li title={title}><a href={`#${id}`} class={className}>{title}</a></li>)
}) })
const showApi = this.$route.path.indexOf('/components/') !== -1 const showApi = this.$route.path.indexOf('/components/') !== -1
return ( return (
<a-affix> <a-anchor>
<ul id='demo-toc' class='toc'> {lis}
{lis} {showApi ? <a-anchor-link title='API' href='#API' /> : ''}
{showApi ? <li title='API' key='API'> </a-anchor>
<a
href='#API'
class={{
current: window.location.hash === '#API',
}}
>API</a>
</li> : ''}
</ul>
</a-affix>
) )
}, },
getDocsMenu (isCN) { getDocsMenu (isCN) {
@ -160,7 +149,7 @@ export default {
const MenuGroup = [] const MenuGroup = []
for (const [type, menus] of Object.entries(menuConfig)) { for (const [type, menus] of Object.entries(menuConfig)) {
const MenuItems = [] const MenuItems = []
_.sortBy(menus, ['title']).forEach(({ title, subtitle }) => { sortBy(menus, ['title']).forEach(({ title, subtitle }) => {
const linkValue = isCN const linkValue = isCN
? [<span>{title}</span>, <span class='chinese'>{subtitle}</span>] ? [<span>{title}</span>, <span class='chinese'>{subtitle}</span>]
: [<span>{title}</span>] : [<span>{title}</span>]
@ -183,7 +172,8 @@ export default {
if (!isCN) { if (!isCN) {
locale = enUS locale = enUS
} }
this.resetDocumentTitle(AllDemo[titleMap[reName]], reName, isCN) const config = AllDemo[titleMap[reName]]
this.resetDocumentTitle(config, reName, isCN)
return ( return (
<div class='page-wrapper'> <div class='page-wrapper'>
<Header searchData={searchData} name={name}/> <Header searchData={searchData} name={name}/>
@ -205,11 +195,11 @@ export default {
</a-col> </a-col>
<a-col span={18}> <a-col span={18}>
<div class='content main-container'> <div class='content main-container'>
<div class='toc-affix' style='width: 110px;'> <div class='toc-affix' style='width: 120px;'>
{this.getSubMenu(isCN)} {this.getSubMenu(isCN)}
</div> </div>
{this.showDemo ? <Provider store={this.store} key={isCN ? 'cn' : 'en'}> {this.showDemo ? <Provider store={this.store} key={isCN ? 'cn' : 'en'}>
<router-view></router-view> <router-view class={`demo-cols-${config.cols || 2}`}></router-view>
</Provider> : ''} </Provider> : ''}
{this.showApi ? <div class='markdown api-container' ref='doc'> {this.showApi ? <div class='markdown api-container' ref='doc'>
<router-view></router-view> <router-view></router-view>

View File

@ -84,3 +84,6 @@
border: none; border: none;
} }
} }
.toc-affix .ant-affix {
overflow: visible;
}

View File

@ -59,11 +59,14 @@ module.exports = merge(baseWebpackConfig, {
}, },
}), }),
new webpack.optimize.CommonsChunkPlugin({ new webpack.optimize.CommonsChunkPlugin({
name: 'manifest', name: 'vender',
minChunks: Infinity, minChunks: function (module) {
return /node_modules/.test(module.context)
},
}), }),
new webpack.optimize.CommonsChunkPlugin({ new webpack.optimize.CommonsChunkPlugin({
name: 'vender', name: 'manifest',
minChunks: Infinity,
}), }),
new webpack.optimize.UglifyJsPlugin({ new webpack.optimize.UglifyJsPlugin({
compress: { compress: {