ant-design/site/entry/index.jsx

80 lines
3.1 KiB
React
Raw Normal View History

2016-02-29 14:08:40 +08:00
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, IndexRoute, hashHistory } from 'react-router';
2016-03-02 11:57:37 +08:00
import * as utils from './utils';
2016-02-29 14:08:40 +08:00
import '../common/lib';
import App from '../component/App';
import Home from '../component/Home';
import Article from '../component/Article';
import introduce from '../../_site/data/introduce';
import gettingStarted from '../../_site/data/getting-started';
import install from '../../_site/data/install';
import upgradeNotes from '../../_site/data/upgrade-notes';
import changelog from '../../_site/data/changelog';
import ReactComponents from '../component/ReactComponents';
import ComponentDoc from '../component/ComponentDoc';
import componentDocsList from '../../_site/data/component-docs-list';
import demosList from '../../_site/data/demos-list';
2016-03-02 11:57:37 +08:00
import practice from '../../_site/data/practice';
import pattern from '../../_site/data/pattern';
2016-03-03 11:12:46 +08:00
import spec from '../../_site/data/spec';
2016-03-02 11:57:37 +08:00
import resource from '../../_site/data/resource';
2016-02-29 14:08:40 +08:00
const Introduce = () => <Article content={introduce[0]} />;
const GettingStarted = () => <Article content={gettingStarted[0]} />;
const Install = () => <Article content={install[0]} />;
const UpgradeNotes = () => <Article content={upgradeNotes[0]} />;
const Changelog = () => <Article content={changelog[0]} />;
const demosListChildren = componentDocsList.map((componentDoc) => {
const key = componentDoc.meta.english.toLowerCase();
const ComponentDocWrapper =
() => <ComponentDoc doc={componentDoc} demos={demosList[key]} />;
return <Route path={key} component={ComponentDocWrapper} key={key} />;
});
2016-03-03 11:12:46 +08:00
const Practice = utils.generateContainer('practice', practice.menuItems);
2016-03-03 17:23:08 +08:00
const practiceChildren = utils.generateChildren(practice);
2016-03-02 11:57:37 +08:00
2016-03-03 11:12:46 +08:00
const Pattern = utils.generateContainer('pattern', pattern.menuItems);
2016-03-03 17:23:08 +08:00
const patternChildren = utils.generateChildren(pattern);
2016-03-02 11:57:37 +08:00
2016-03-03 11:12:46 +08:00
const Spec = utils.generateContainer('spec', spec.menuItems);
2016-03-03 17:23:08 +08:00
const specChildren = utils.generateChildren(spec);
2016-03-03 11:12:46 +08:00
const Resource = utils.generateContainer('resource', resource.menuItems);
2016-03-03 17:23:08 +08:00
const resourceChildren = utils.generateChildren(resource);
2016-02-29 14:08:40 +08:00
2016-03-03 11:12:46 +08:00
ReactDOM.render(
<Router history={hashHistory}>
<Route path="/" component={App}>
<IndexRoute component={Home} />
<Route path="components" component={ReactComponents}>
<IndexRoute component={Introduce} />
<Route path="introduce" component={Introduce} />
<Route path="getting-started" component={GettingStarted} />
<Route path="install" component={Install} />
<Route path="upgrade-notes" component={UpgradeNotes} />
<Route path="changelog" component={Changelog} />
{ demosListChildren }
</Route>
<Route path="practice" component={Practice}>
{ practiceChildren }
</Route>
<Route path="pattern" component={Pattern}>
{ patternChildren }
</Route>
<Route path="spec" component={Spec}>
{ specChildren }
</Route>
<Route path="resource" component={Resource}>
{ resourceChildren }
</Route>
2016-02-29 14:08:40 +08:00
</Route>
2016-03-03 11:12:46 +08:00
</Router>
, document.getElementById('react-content')
);