diff --git a/packages/netlify-cms-core/src/components/App/App.js b/packages/netlify-cms-core/src/components/App/App.js index 46ca82a0..da598a48 100644 --- a/packages/netlify-cms-core/src/components/App/App.js +++ b/packages/netlify-cms-core/src/components/App/App.js @@ -49,6 +49,23 @@ const ErrorCodeBlock = styled.pre` line-height: 1.5; `; +const getDefaultPath = collections => { + return `/collections/${collections.first().get('name')}`; +}; + +const RouteInCollection = ({ collections, render, ...props }) => { + const defaultPath = getDefaultPath(collections); + return ( + { + const collectionExists = collections.get(routeProps.match.params.name); + return collectionExists ? render(routeProps) : ; + }} + /> + ); +}; + class App extends React.Component { static propTypes = { auth: ImmutablePropTypes.map, @@ -155,7 +172,7 @@ class App extends React.Component { return this.authenticating(t); } - const defaultPath = `/collections/${collections.first().get('name')}`; + const defaultPath = getDefaultPath(collections); const hasWorkflow = publishMode === EDITORIAL_WORKFLOW; return ( @@ -178,25 +195,29 @@ class App extends React.Component { {hasWorkflow ? : null} - { - const collectionExists = collections.get(props.match.params.name); - return collectionExists ? : ; - }} + render={props => } /> - } /> - + } + /> } /> - { const { collectionName, entryName } = match.params; return ;