ant-design/site/entry/utils.js

23 lines
665 B
JavaScript
Raw Normal View History

2016-03-02 11:57:37 +08:00
import React from 'react';
import { Route, IndexRedirect } from 'react-router';
import Article from '../component/Article';
export function generateChildren(pagesData) {
const children = pagesData.map((pageData, index) => {
const ArticleWrapper = () => <Article content={pageData} />;
return (
<Route key={index}
path={pageData.meta.english.toLowerCase()}
component={ArticleWrapper} />
);
});
const firstChild = pagesData.find((pageData) => {
return pageData.meta.disabled !== 'true';
});
children.unshift(
<IndexRedirect key="index"
to={firstChild.meta.english.toLowerCase()} />
);
return children;
}