import React from 'react'; import { Link } from 'react-router'; import { Row, Col, Menu } from '../../../'; import * as utils from '../utils'; import componentsList from '../../../_site/data/components-list'; const componentMenuItems = []; ['基本', '表单', '展示', '导航', '其它'].forEach((category) => { const grandChildren = componentsList[category].map((item) => { const key = item.english.toLowerCase(); return ( {item.title} ); }); componentMenuItems.push( { grandChildren } ); }); export default class ReactComponents extends React.Component { getTopLevelMenuItems() { return [ Ant Design of React , 快速上手 , 安装 , 升级指南 , 更新日志 , ]; } render() { const routes = this.props.routes; const activeMenuItem = routes[routes.length - 1].path; const topLevelMenuItems = this.getTopLevelMenuItems(); const menuItems = topLevelMenuItems.concat( utils.flattenMenu(componentMenuItems) ); const activeMenuItemIndex = menuItems.findIndex((menuItem) => { return menuItem.key === activeMenuItem; }); const prev = menuItems[activeMenuItemIndex - 1]; const next = menuItems[activeMenuItemIndex + 1]; return ( { topLevelMenuItems } { componentMenuItems } { this.props.children }
{ !!prev ? React.cloneElement(prev.props.children, { className: 'prev-page' }) : null } { !!next ? React.cloneElement(next.props.children, { className: 'next-page' }) : null }
); } }