1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-02-24 11:33:09 +01:00

90 lines
2.6 KiB
TypeScript
Raw Normal View History

2021-09-05 22:09:22 +02:00
import { Box, Container, Link, Text } from '@chakra-ui/react';
2021-09-03 16:21:20 +02:00
import { GlobalHeader } from '../../components/global-header';
import { OpensourceBanner } from '../../components/opensource-banner';
import { Footer } from '../../components/footer';
import { ContentPageHeader } from '../../components/content-page-header';
import MdRenderer from '../../components/md-renderer';
import { getAllVideos, getVideoById, VideoType } from '../../lib/video';
import Helmet from '../../components/helmet';
2021-09-03 16:21:20 +02:00
type VideoProps = {
video: VideoType;
};
export default function Video(props: VideoProps) {
const { video } = props;
const VideoContent = require(`../../content/videos/${video.id}.md`).default;
return (
<Box bg='white' minH='100vh'>
<GlobalHeader />
<Helmet title={video.title} description={video.description} />
2021-09-03 16:21:20 +02:00
<Box mb='60px'>
<ContentPageHeader
title={video.title}
subtitle={video.description}
formattedDate={video.formattedUpdatedAt!}
2021-09-03 16:54:35 +02:00
subLink={video.youtubeLink ? {
2021-09-03 16:21:20 +02:00
text: 'Watch on YouTube',
2021-09-03 16:54:35 +02:00
url: video.youtubeLink
} : undefined}
2021-09-03 16:21:20 +02:00
author={{
twitter: video.author?.twitter!,
name: video.author?.name!,
picture: video.author?.picture!
}}
/>
<Container maxW={'container.md'} position='relative'>
2021-09-05 22:09:22 +02:00
{video.youtubeLink && (
<Text mb='18px'>We are working on a better watch page for now this <Link fontWeight={600}
textDecoration={'underline'}
href={video.youtubeLink}
target='_blank'>video is best
viewed on YouTube</Link>.</Text>)}
2021-09-03 16:21:20 +02:00
<MdRenderer>
<VideoContent />
</MdRenderer>
</Container>
</Box>
<OpensourceBanner />
<Footer />
</Box>
);
}
type StaticPathItem = {
params: {
video: string
}
};
export async function getStaticPaths() {
const videos = getAllVideos();
const paramsList: StaticPathItem[] = videos.map(video => ({
params: { 'video': video.id }
}));
return {
paths: paramsList,
fallback: false
};
}
type ContextType = {
params: {
video: string
}
};
export async function getStaticProps(context: ContextType) {
const videoId: string = context?.params?.video;
return {
props: {
video: getVideoById(videoId)
}
};
}