@ -1,50 +1,61 @@
import { Box , Button , Container , SimpleGrid , S tack } from '@chakra-ui/react' ;
import { Box , Button , Container , Stack } from '@chakra-ui/react' ;
import { DownloadIcon , EmailIcon } from '@chakra-ui/icons' ;
import { DownloadIcon , EmailIcon } from '@chakra-ui/icons' ;
import styled from 'styled-components' ;
import Image from 'next/image' ;
import { GlobalHeader } from '../../components/global-header' ;
import { GlobalHeader } from '../../components/global-header' ;
import { OpensourceBanner } from '../../components/opensource-banner' ;
import { OpensourceBanner } from '../../components/opensource-banner' ;
import { UpdatesBanner } from '../../components/updates-banner' ;
import { UpdatesBanner } from '../../components/updates-banner' ;
import { Footer } from '../../components/footer' ;
import { Footer } from '../../components/footer' ;
import { PageHeader } from '../../components/page-header' ;
import { PageHeader } from '../../components/page-header' ;
import { getAllRoadmaps , getRoadmapById , RoadmapType } from '../../lib/roadmap' ;
import MdRenderer from '../../components/md-renderer' ;
const RoadmapBody = styled . div `
type RoadmapProps = {
margin - bottom : 30px ;
roadmap : RoadmapType ;
font - size : 15px ;
} ;
h1 {
function ImageRoadmap ( props : RoadmapProps ) {
font - size : 32px ;
const { roadmap } = props ;
font - weight : 700 ;
if ( ! roadmap . imagePath ) {
return null ;
}
}
p {
return (
line - height : 25px ;
< Container maxW = { '900px' } position = 'relative' >
margin - bottom : 20px
< Box mb = '30px' >
}
< img alt = 'Frontend Roadmap' src = { roadmap . imagePath } / >
< / Box >
ul , ol {
< / Container >
margin : 0 0 20 px 40 px ;
) ;
}
li + li {
function TextualRoadmap ( props : RoadmapProps ) {
margin - top : 7px ;
const { roadmap } = props ;
}
if ( ! roadmap . contentPath ) {
return null ;
}
}
img {
// Remove trailing slashes
max - width : 100 % ;
const normalizedPath = roadmap . contentPath . replace ( /^\// , '' ) ;
}
const RoadmapContent = require ( ` ../../content/ ${ normalizedPath } ` ) . default ;
` ;
return (
< Container maxW = { 'container.md' } position = 'relative' >
< MdRenderer >
< RoadmapContent / >
< / MdRenderer >
< / Container >
) ;
}
export default function Roadmap() {
export default function Roadmap ( props : RoadmapProps ) {
const isImageOnly = true ;
const { roadmap } = props ;
return (
return (
< Box bg = 'white' minH = '100vh' >
< Box bg = 'white' minH = '100vh' >
< GlobalHeader / >
< GlobalHeader / >
< Box mb = '60px' >
< Box mb = '60px' >
< PageHeader
< PageHeader
title = { 'Frontend Developer' }
title = { roadmap . title }
subtitle = { 'Step by step guide to becoming a modern frontend developer' }
subtitle = { roadmap . description }
>
>
< Stack mt = '20px' isInline >
< Stack mt = '20px' isInline >
< Button size = 'xs' py = '14px' px = '10px' leftIcon = { < DownloadIcon / > } colorScheme = 'yellow' variant = 'solid' >
< Button size = 'xs' py = '14px' px = '10px' leftIcon = { < DownloadIcon / > } colorScheme = 'yellow' variant = 'solid' >
@ -55,11 +66,9 @@ export default function Roadmap() {
< / Button >
< / Button >
< / Stack >
< / Stack >
< / PageHeader >
< / PageHeader >
< Container maxW = { isImageOnly ? '900px' : 'container.md' } position = 'relative' >
< RoadmapBody >
< ImageRoadmap roadmap = { roadmap } / >
< img alt = 'Frontend Roadmap' src = '/roadmaps/frontend.png' / >
< TextualRoadmap roadmap = { roadmap } / >
< / RoadmapBody >
< / Container >
< / Box >
< / Box >
< OpensourceBanner / >
< OpensourceBanner / >
@ -68,3 +77,37 @@ export default function Roadmap() {
< / Box >
< / Box >
) ;
) ;
}
}
type StaticPathItem = {
params : {
roadmap : string
}
} ;
export async function getStaticPaths() {
const roadmaps = getAllRoadmaps ( ) ;
const paramsList : StaticPathItem [ ] = roadmaps . map ( roadmap = > ( {
params : { 'roadmap' : roadmap . id }
} ) ) ;
return {
paths : paramsList ,
fallback : false
} ;
}
type ContextType = {
params : {
roadmap : string
}
} ;
export async function getStaticProps ( context : ContextType ) {
const roadmapId : string = context ? . params ? . roadmap ;
return {
props : {
roadmap : getRoadmapById ( roadmapId )
}
} ;
}