site: unify link

This commit is contained in:
Benjy Cui 2016-08-03 15:41:18 +08:00
parent 7ea4dfa501
commit dfc26727d8
3 changed files with 5 additions and 3 deletions

View File

@ -37,7 +37,7 @@ module.exports = {
path: 'changelog',
component: contentTmpl,
}, {
path: 'components/:children',
path: 'components/:children/',
component: contentTmpl,
}, {
path: 'docs/spec/:children',

View File

@ -59,7 +59,7 @@ export default class MainContent extends React.Component {
const disabled = item.disabled;
const url = item.filename.replace(/(\/index)?((\.zh-CN)|(\.en-US))?\.md$/i, '').toLowerCase();
const child = !item.link ?
<Link to={url} disabled={disabled}>
<Link to={/^components/.test(url) ? `${url}/` : url} disabled={disabled}>
{text}
</Link> :
<a href={item.link} target="_blank" disabled={disabled}>

View File

@ -90,7 +90,9 @@ export default class Header extends React.Component {
render() {
const { location, components } = this.props;
const module = location.pathname.split('/').slice(0, -1).join('/');
const module = location.pathname.replace(/\/$/, '')
.split('/').slice(0, -1)
.join('/');
let activeMenuItem = module || 'home';
if (activeMenuItem === 'components' || location.pathname === 'changelog') {
activeMenuItem = 'docs/react';