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

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

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

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

Loading…
Cancel
Save