import React from 'react';
import { Box, Button, Container, Flex, Heading, Image, Input, Text } from '@chakra-ui/react';
import { GlobalHeader } from '../../components/global-header';
import { OpensourceBanner } from '../../components/opensource-banner';
import { Footer } from '../../components/footer';
import {
filterRoadmapsByIds,
getAllRoadmaps,
getRoadmapById,
isInteractiveRoadmap,
RoadmapType
} from '../../lib/roadmap';
import MdRenderer from '../../components/md-renderer';
import Helmet from '../../components/helmet';
import { RoadmapPageHeader } from '../../components/roadmap/roadmap-page-header';
import { InteractiveRoadmapRenderer } from './interactive';
import { SIGNUP_EMAIL_INPUT_NAME, SIGNUP_FORM_ACTION } from '../signup';
import { BellIcon, EmailIcon } from '@chakra-ui/icons';
import { RelatedRoadmaps } from '../../components/related-roadmaps';
import { TeamsBanner } from '../../components/teams-banner';
type RoadmapProps = {
roadmap: RoadmapType;
};
function ImageRoadmap(props: RoadmapProps) {
const { roadmap } = props;
if (isInteractiveRoadmap(roadmap.id)) {
return ;
}
if (!roadmap.imageUrl) {
return null;
}
return (
);
}
function TextualRoadmap(props: RoadmapProps) {
const { roadmap } = props;
if (!roadmap.landingPath) {
return null;
}
// Remove trailing slashes
const normalizedPath = roadmap.landingPath.replace(/^\//, '');
const LandingContent = require(`../../content/${normalizedPath}`).default;
return (
);
}
function UpcomingRoadmap(props: RoadmapProps) {
const { roadmap } = props;
if (!roadmap.isUpcoming) {
return null;
}
return (
Upcoming Roadmap
Please check back later or subscribe below.
);
}
type RoadmapPageProps = RoadmapProps & {
relatedRoadmaps: RoadmapType[]
};
export default function Roadmap(props: RoadmapPageProps) {
const { roadmap, relatedRoadmaps } = props;
return (
);
}
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;
const roadmap: RoadmapType = getRoadmapById(roadmapId)!;
const relatedRoadmaps: RoadmapType[] = filterRoadmapsByIds(roadmap?.relatedRoadmaps || []);
return {
props: {
roadmap,
relatedRoadmaps,
}
};
}