From 250f1d59e68212b357dfc926365ec7e22362b98e Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Tue, 29 Oct 2019 17:46:54 +0400 Subject: [PATCH] Add roadmap page --- components/featured-content/index.js | 1 - components/page-header/index.js | 1 - data/roadmaps.json | 17 +++++++++++++++++ pages/[fallback].js | 23 +++++++++++++---------- pages/roadmaps/[roadmap].js | 19 +++++++++++++++++++ pages/roadmaps/index.js | 11 +++++++++++ 6 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 data/roadmaps.json create mode 100644 pages/roadmaps/[roadmap].js create mode 100644 pages/roadmaps/index.js diff --git a/components/featured-content/index.js b/components/featured-content/index.js index b9e615e04..6b2b179d8 100644 --- a/components/featured-content/index.js +++ b/components/featured-content/index.js @@ -7,7 +7,6 @@ const FeaturedContent = (props) => ( - { /**/ } ); diff --git a/components/page-header/index.js b/components/page-header/index.js index dca2a5f4d..7abe7a8ae 100644 --- a/components/page-header/index.js +++ b/components/page-header/index.js @@ -11,7 +11,6 @@ const PageHeader = () => (
Roadmaps Guides - Journeys FAQs Sign Up
diff --git a/data/roadmaps.json b/data/roadmaps.json new file mode 100644 index 000000000..7b4d01175 --- /dev/null +++ b/data/roadmaps.json @@ -0,0 +1,17 @@ +[ + { + "title": "Frontend Developer", + "description": "Roadmap to becoming a frontend developer", + "slug": "frontend" + }, + { + "title": "Backend Developer", + "description": "Roadmap to becoming a backend developer", + "slug": "backend" + }, + { + "title": "DevOps", + "description": "Roadmap for DevOps or any other Operations Role", + "slug": "devops" + } +] \ No newline at end of file diff --git a/pages/[fallback].js b/pages/[fallback].js index b6d43cffc..e6f4dd519 100644 --- a/pages/[fallback].js +++ b/pages/[fallback].js @@ -1,16 +1,19 @@ -import { useRouter } from 'next/router' +import { useRouter } from 'next/router'; +import Roadmap from './roadmaps/[roadmap]'; +import roadmapsList from "../data/roadmaps.json"; -// Fallback page to handle the routing for the old roadmap pages -const Fallback = () => { +// Fallback page to handle the old roadmap pages implementation +const OldRoadmap = () => { const router = useRouter(); const { fallback } = router.query; - return ( -
-

{ fallback }

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi dolorum ea earum exercitationem fuga magnam nihil nostrum numquam optio provident quaerat repellendus, repudiandae vitae voluptas, voluptatibus. Consequuntur doloremque maxime perferendis!

-
- ); + // Render the roadmap if it exists, otherwise 404 + const roadmapExists = !!roadmapsList.find(roadmap => roadmap.slug === fallback); + if (roadmapExists) { + return + } + + return

404

; }; -export default Fallback; \ No newline at end of file +export default OldRoadmap; \ No newline at end of file diff --git a/pages/roadmaps/[roadmap].js b/pages/roadmaps/[roadmap].js new file mode 100644 index 000000000..cde6c4248 --- /dev/null +++ b/pages/roadmaps/[roadmap].js @@ -0,0 +1,19 @@ +import { useRouter } from 'next/router'; +import DefaultLayout from '../../layouts/default/index'; +import PageHeader from '../../components/page-header/index'; + +const Roadmap = (props) => { + const router = useRouter(); + const { + roadmap = props.roadmap, + } = router.query; + + return ( + + +

Show roadmap for { roadmap } here

+
+ ); +}; + +export default Roadmap; \ No newline at end of file diff --git a/pages/roadmaps/index.js b/pages/roadmaps/index.js new file mode 100644 index 000000000..279c97ad8 --- /dev/null +++ b/pages/roadmaps/index.js @@ -0,0 +1,11 @@ +import DefaultLayout from '../../layouts/default/index'; +import PageHeader from '../../components/page-header/index'; + +const Roadmap = () => ( + + +

Show all roadmaps here

+
+); + +export default Roadmap; \ No newline at end of file