Files
developer-roadmap/pages/[fallback].js

19 lines
555 B
JavaScript
Raw Normal View History

2019-10-29 17:46:54 +04:00
import { useRouter } from 'next/router';
import Roadmap from './roadmaps/[roadmap]';
import roadmapsList from "../data/roadmaps.json";
2019-10-28 00:40:08 +04:00
2019-10-29 17:46:54 +04:00
// Fallback page to handle the old roadmap pages implementation
const OldRoadmap = () => {
2019-10-28 00:40:08 +04:00
const router = useRouter();
const { fallback } = router.query;
2019-10-29 17:46:54 +04:00
// Render the roadmap if it exists, otherwise 404
const roadmapExists = !!roadmapsList.find(roadmap => roadmap.slug === fallback);
if (roadmapExists) {
return <Roadmap roadmap={ fallback } />
}
return <h1>404</h1>;
2019-10-28 00:40:08 +04:00
};
2019-10-29 17:46:54 +04:00
export default OldRoadmap;