mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 11:39:28 +08:00
site: add redirect
This commit is contained in:
parent
7db2a33f1d
commit
fb3776dbd3
@ -5,14 +5,6 @@ import { Row, Col, Menu } from '../../../';
|
||||
import config from '../../website.config';
|
||||
const SubMenu = Menu.SubMenu;
|
||||
|
||||
const fileNameUrlMap = {
|
||||
'docs/react/introduce': 'components/introduce',
|
||||
'docs/react/getting-started': 'components/getting-started',
|
||||
'docs/react/install': 'components/install',
|
||||
'docs/react/upgrade-notes': 'components/upgrade-notes',
|
||||
CHANGELOG: 'components/changelog',
|
||||
};
|
||||
|
||||
export default class MainContent extends React.Component {
|
||||
componentDidMount() {
|
||||
this.componentDidUpdate();
|
||||
@ -54,7 +46,7 @@ export default class MainContent extends React.Component {
|
||||
const disabled = item.disabled === 'true';
|
||||
const url = item.fileName.replace(/(\/index)?\.md$/i, '');
|
||||
const child = !item.link ?
|
||||
<Link to={fileNameUrlMap[url] || url} disabled={disabled}>
|
||||
<Link to={url} disabled={disabled}>
|
||||
{ text }
|
||||
</Link> :
|
||||
<a href={item.link} target="_blank" disabled={disabled}>
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { Router, Route, IndexRoute, hashHistory } from 'react-router';
|
||||
import { Router, Route, IndexRoute, Redirect, hashHistory } from 'react-router';
|
||||
import antd from '../../';
|
||||
import * as utils from './utils';
|
||||
import '../common/lib';
|
||||
@ -18,19 +18,19 @@ window.react = React;
|
||||
window['react-dom'] = ReactDOM;
|
||||
window.antd = antd;
|
||||
|
||||
const ReactComponents = utils.generateContainer('components', reactComponents);
|
||||
const ReactComponents = utils.generateContainer(reactComponents);
|
||||
const reactComponentsChildren = utils.generateChildren(reactComponents);
|
||||
|
||||
const Practice = utils.generateContainer('practice', practice);
|
||||
const Practice = utils.generateContainer(practice);
|
||||
const practiceChildren = utils.generateChildren(practice);
|
||||
|
||||
const Pattern = utils.generateContainer('pattern', pattern);
|
||||
const Pattern = utils.generateContainer(pattern);
|
||||
const patternChildren = utils.generateChildren(pattern);
|
||||
|
||||
const Spec = utils.generateContainer('spec', spec);
|
||||
const Spec = utils.generateContainer(spec);
|
||||
const specChildren = utils.generateChildren(spec);
|
||||
|
||||
const Resource = utils.generateContainer('resource', resource);
|
||||
const Resource = utils.generateContainer(resource);
|
||||
const resourceChildren = utils.generateChildren(resource);
|
||||
|
||||
ReactDOM.render(
|
||||
@ -40,6 +40,12 @@ ReactDOM.render(
|
||||
<Route path="components" component={ReactComponents}>
|
||||
{ reactComponentsChildren }
|
||||
</Route>
|
||||
<Redirect from="docs/react/introduce" to="components/introduce" />
|
||||
<Redirect from="docs/react/getting-started"
|
||||
to="components/getting-started" />
|
||||
<Redirect from="docs/react/install" to="components/install" />
|
||||
<Redirect from="docs/react/upgrade-notes" to="components/upgrade-notes" />
|
||||
<Redirect from="CHANGELOG" to="components/changelog" />
|
||||
<Route path="docs/practice" component={Practice}>
|
||||
{ practiceChildren }
|
||||
</Route>
|
||||
|
@ -35,12 +35,11 @@ function getMenuItems(data) {
|
||||
return menuItems;
|
||||
}
|
||||
|
||||
export function generateContainer(category, data) {
|
||||
export function generateContainer(data) {
|
||||
const menuItems = getMenuItems(data);
|
||||
return (props) => {
|
||||
return (
|
||||
<MainContent {...props}
|
||||
category={category} menuItems={menuItems} />
|
||||
<MainContent {...props} menuItems={menuItems} />
|
||||
);
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user