Roadmap summary section

pull/1331/head
Kamran Ahmed 5 years ago
parent 61a585614e
commit 7e9d477bc9
  1. 7
      components/roadmap-summary/index.js
  2. 5
      lib/roadmap.js
  3. 2
      pages/[fallback]/index.js
  4. 5
      pages/roadmaps/[roadmap]/index.js

@ -12,6 +12,11 @@ import {
VersionList, VersionList,
} from './style'; } from './style';
const isActiveRoadmap = (loadedVersion, roadmapVersion) => (
(loadedVersion === roadmapVersion) ||
(loadedVersion === 'latest' && parseInt(roadmapVersion, 10) === (new Date()).getFullYear())
);
const RoadmapSummary = ({ roadmap }) => ( const RoadmapSummary = ({ roadmap }) => (
<SummaryContainer> <SummaryContainer>
<Header> <Header>
@ -21,7 +26,7 @@ const RoadmapSummary = ({ roadmap }) => (
{ (roadmap.versions || []).map(versionItem => ( { (roadmap.versions || []).map(versionItem => (
<Link href={ `${roadmap.slug}/${versionItem}` } passHref key={ versionItem }> <Link href={ `${roadmap.slug}/${versionItem}` } passHref key={ versionItem }>
<VersionLink className={ classNames({ <VersionLink className={ classNames({
active: versionItem === roadmap.version, active: isActiveRoadmap(versionItem, roadmap.version),
}) }>{ versionItem } Version</VersionLink> }) }>{ versionItem } Version</VersionLink>
</Link> </Link>
)) } )) }

@ -19,7 +19,10 @@ export const getRequestedRoadmap = req => {
legacyUrlWithoutVersion, legacyUrlWithoutVersion,
]; ];
const foundRoadmap = roadmaps.find(roadmap => urlToSlugList.includes(roadmap.slug)) || {}; const foundRoadmap = roadmaps.find(roadmap => urlToSlugList.includes(roadmap.slug));
if (!foundRoadmap) {
return null;
}
return { return {
...foundRoadmap, ...foundRoadmap,

@ -9,7 +9,7 @@ const OldRoadmap = ({ roadmap }) => {
return <Roadmap roadmap={ roadmap } /> return <Roadmap roadmap={ roadmap } />
} }
return <Error status={ 404 } />; return <Error statusCode={ 404 } />;
}; };
OldRoadmap.getInitialProps = serverOnlyProps(({ req }) => { OldRoadmap.getInitialProps = serverOnlyProps(({ req }) => {

@ -1,3 +1,4 @@
import Error from 'next/error';
import DefaultLayout from '../../../layouts/default'; import DefaultLayout from '../../../layouts/default';
import { serverOnlyProps } from '../../../lib/server'; import { serverOnlyProps } from '../../../lib/server';
import PageHeader from '../../../components/page-header'; import PageHeader from '../../../components/page-header';
@ -6,6 +7,10 @@ import { getRequestedRoadmap } from '../../../lib/roadmap';
import RoadmapSummary from '../../../components/roadmap-summary'; import RoadmapSummary from '../../../components/roadmap-summary';
const Roadmap = ({ roadmap }) => { const Roadmap = ({ roadmap }) => {
if (!roadmap) {
return <Error statusCode={ 404 } />
}
return ( return (
<DefaultLayout> <DefaultLayout>
<PageHeader /> <PageHeader />

Loading…
Cancel
Save