ant-design/site/entry/index.jsx

59 lines
1.9 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';
2016-03-02 11:57:37 +08:00
import practice from '../../_site/data/practice';
import pattern from '../../_site/data/pattern';
2016-03-04 18:06:34 +08:00
import reactComponents from '../../_site/data/react-components';
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
2016-03-04 18:06:34 +08:00
function addFileNameToMeta(data) {
Object.keys(data).forEach((key) => {
data[key].meta.fileName = key;
});
return data;
}
2016-02-29 14:08:40 +08:00
2016-03-04 18:06:34 +08:00
const ReactComponents = utils.generateContainer('components', reactComponents);
const reactComponentsChildren = utils.generateChildren(addFileNameToMeta(reactComponents));
2016-02-29 14:08:40 +08:00
2016-03-04 15:19:23 +08:00
const Practice = utils.generateContainer('practice', practice);
2016-03-03 17:23:08 +08:00
const practiceChildren = utils.generateChildren(practice);
2016-03-02 11:57:37 +08:00
2016-03-04 15:19:23 +08:00
const Pattern = utils.generateContainer('pattern', pattern);
2016-03-03 17:23:08 +08:00
const patternChildren = utils.generateChildren(pattern);
2016-03-02 11:57:37 +08:00
2016-03-04 15:19:23 +08:00
const Spec = utils.generateContainer('spec', spec);
2016-03-04 18:06:34 +08:00
const specChildren = utils.generateChildren(addFileNameToMeta(spec));
2016-03-03 11:12:46 +08:00
2016-03-04 15:19:23 +08:00
const Resource = utils.generateContainer('resource', resource);
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}>
2016-03-04 18:06:34 +08:00
{ reactComponentsChildren }
2016-03-03 11:12:46 +08:00
</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')
);