Add Link component

This commit is contained in:
Tom Raithel
2017-02-21 21:54:38 +01:00
parent c0dd1809e3
commit f284b4b310
9 changed files with 76 additions and 22 deletions

View File

@@ -3,10 +3,11 @@ import PageIndex from './PageIndex';
import PageOverview from './PageOverview';
import PageHelp from './PageHelp';
import PageQuadrant from './PageQuadrant';
import { quadrants } from '../../common/config';
import PageItem from './PageItem';
import { quadrants, getItemPageNames } from '../../common/config';
const getPageByName = (pageName) => {
const getPageByName = (items, pageName) => {
if (pageName === 'index') {
return PageIndex;
}
@@ -19,11 +20,14 @@ const getPageByName = (pageName) => {
if (quadrants.includes(pageName)) {
return PageQuadrant;
}
if (getItemPageNames(items).includes(pageName)) {
return PageItem;
}
return 'div';
}
export default function Router({ pageName, ...props}) {
const Comp = getPageByName(pageName);
const Comp = getPageByName(props.items, pageName);
return <Comp {...props} pageName={pageName} />;
}