Normalize filename and url in videos

pull/1331/head
Kamran Ahmed 3 years ago
parent ac984346e8
commit e800e3b6ce
  1. 44
      content/videos.json
  2. 0
      content/videos/all-about-http-caching.md
  3. 0
      content/videos/freeze-and-seal-objects-in-javascript.md
  4. 0
      content/videos/transport-protocols-tcp-vs-udp.md
  5. 2
      lib/video.ts
  6. 4
      pages/index.tsx
  7. 32
      pages/watch/[video].jsx
  8. 84
      pages/watch/[video].tsx
  9. 2
      pages/watch/index.tsx

@ -1,10 +1,8 @@
[ [
{ {
"id": "tcp-udp", "id": "transport-protocols-tcp-vs-udp",
"title": "Transport Protocols: TCP vs UDP", "title": "Transport Protocols: TCP vs UDP",
"description": "Learn about the Transport Layer of the TCP/IP model and different transport protocols.", "description": "Learn about the Transport Layer of the TCP/IP model and different transport protocols.",
"url": "/watch/transport-protocols-tcp-vs-udp",
"fileName": "tcp-udp.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "10 minutes", "duration": "10 minutes",
@ -15,8 +13,6 @@
"id": "tcp-ip-model", "id": "tcp-ip-model",
"title": "TCP/IP Model Explained", "title": "TCP/IP Model Explained",
"description": "Learn what is TCP/IP Model and the different layers involved.", "description": "Learn what is TCP/IP Model and the different layers involved.",
"url": "/watch/tcp-ip-model",
"fileName": "tcp-ip-model.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "5 minutes", "duration": "5 minutes",
@ -27,8 +23,6 @@
"id": "osi-model", "id": "osi-model",
"title": "OSI Model Explained", "title": "OSI Model Explained",
"description": "Learn what is OSI Model and the different layers involved.", "description": "Learn what is OSI Model and the different layers involved.",
"url": "/watch/osi-model",
"fileName": "osi-model.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "7 minutes", "duration": "7 minutes",
@ -36,11 +30,9 @@
"createdAt": "2020-07-09T19:59:14.191Z" "createdAt": "2020-07-09T19:59:14.191Z"
}, },
{ {
"id": "freeze-seal-js", "id": "freeze-and-seal-objects-in-javascript",
"title": "Freeze and Seal in JavaScript", "title": "Freeze and Seal in JavaScript",
"description": "Learn what is OSI Model and the different layers involved.", "description": "Learn what is OSI Model and the different layers involved.",
"url": "/watch/freeze-and-seal-objects-in-javascript",
"fileName": "freeze-seal-js.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "6 minutes", "duration": "6 minutes",
@ -48,11 +40,9 @@
"createdAt": "2020-07-09T19:59:14.191Z" "createdAt": "2020-07-09T19:59:14.191Z"
}, },
{ {
"id": "http-caching", "id": "all-about-http-caching",
"title": "All about HTTP Caching", "title": "All about HTTP Caching",
"description": "Learn what is HTTP caching, places for caching and different caching headers.", "description": "Learn what is HTTP caching, places for caching and different caching headers.",
"url": "/watch/all-about-http-caching",
"fileName": "http-caching.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "13 minutes", "duration": "13 minutes",
@ -63,8 +53,6 @@
"id": "content-delivery-networks", "id": "content-delivery-networks",
"title": "Content Delivery Networks", "title": "Content Delivery Networks",
"description": "Learn what the CDNs are and the difference between push CDN vs pull CDN.", "description": "Learn what the CDNs are and the difference between push CDN vs pull CDN.",
"url": "/watch/content-delivery-networks",
"fileName": "content-delivery-networks.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "4 minutes", "duration": "4 minutes",
@ -75,8 +63,6 @@
"id": "load-balancers-101", "id": "load-balancers-101",
"title": "Load Balancers 101", "title": "Load Balancers 101",
"description": "Learn the basics of load balancers, types and different algorithms.", "description": "Learn the basics of load balancers, types and different algorithms.",
"url": "/watch/load-balancers-101",
"fileName": "load-balancers-101.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "9 minutes", "duration": "9 minutes",
@ -87,8 +73,6 @@
"id": "dns-records", "id": "dns-records",
"title": "DNS Records", "title": "DNS Records",
"description": "Learn what the DNS is and how a website is found on the internet.", "description": "Learn what the DNS is and how a website is found on the internet.",
"url": "/watch/dns-records",
"fileName": "dns-records.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "6 minutes", "duration": "6 minutes",
@ -99,8 +83,6 @@
"id": "dns-explained", "id": "dns-explained",
"title": "DNS and how does it work?", "title": "DNS and how does it work?",
"description": "Learn what the DNS is and how a website is found on the internet.", "description": "Learn what the DNS is and how a website is found on the internet.",
"url": "/watch/dns-explained",
"fileName": "dns-explained.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "5 minutes", "duration": "5 minutes",
@ -111,8 +93,6 @@
"id": "system-design-101", "id": "system-design-101",
"title": "System Design 101", "title": "System Design 101",
"description": "Learn about all the bits and pieces of system design.", "description": "Learn about all the bits and pieces of system design.",
"url": "/watch/system-design-101",
"fileName": "system-design-101.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "7 minutes", "duration": "7 minutes",
@ -123,8 +103,6 @@
"id": "javascript-fetch-api", "id": "javascript-fetch-api",
"title": "JavaScript Fetch API", "title": "JavaScript Fetch API",
"description": "Learn how to use JavaScript's Fetch API to interact with remote API.", "description": "Learn how to use JavaScript's Fetch API to interact with remote API.",
"url": "/watch/javascript-fetch-api",
"fileName": "javascript-fetch-api.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "3 minutes", "duration": "3 minutes",
@ -135,8 +113,6 @@
"id": "scaling-the-unscalable", "id": "scaling-the-unscalable",
"title": "Scaling the Unscalable", "title": "Scaling the Unscalable",
"description": "Learn the basics of System Design and understand how to build a scalable application.", "description": "Learn the basics of System Design and understand how to build a scalable application.",
"url": "/watch/scaling-the-unscalable",
"fileName": "scaling-the-unscalable.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "10 minutes", "duration": "10 minutes",
@ -147,8 +123,6 @@
"id": "promises-in-javascript", "id": "promises-in-javascript",
"title": "All about Promises in JavaScript", "title": "All about Promises in JavaScript",
"description": "Learn how to write asynchronous code in JavaScript using promises.", "description": "Learn how to write asynchronous code in JavaScript using promises.",
"url": "/watch/promises-in-javascript",
"fileName": "promises-in-javascript.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "8 minutes", "duration": "8 minutes",
@ -159,8 +133,6 @@
"id": "how-to-use-github-actions", "id": "how-to-use-github-actions",
"title": "Automate with GitHub Actions", "title": "Automate with GitHub Actions",
"description": "Learn how to implement CI/CD with GitHub Actions", "description": "Learn how to implement CI/CD with GitHub Actions",
"url": "/watch/how-to-use-github-actions",
"fileName": "how-to-use-github-actions.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "6 minutes", "duration": "6 minutes",
@ -171,8 +143,6 @@
"id": "what-is-dependency-injection", "id": "what-is-dependency-injection",
"title": "What is Dependency Injection?", "title": "What is Dependency Injection?",
"description": "Learn what is dependency injection and how to write better code with the help of it.", "description": "Learn what is dependency injection and how to write better code with the help of it.",
"url": "/watch/what-is-dependency-injection",
"fileName": "what-is-dependency-injection.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "3 minutes", "duration": "3 minutes",
@ -183,8 +153,6 @@
"id": "how-to-use-css-variables", "id": "how-to-use-css-variables",
"title": "How to use CSS Variables?", "title": "How to use CSS Variables?",
"description": "Learn how to write scalable CSS using CSS Variables.", "description": "Learn how to write scalable CSS using CSS Variables.",
"url": "/watch/how-to-use-css-variables",
"fileName": "how-to-use-css-variables.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "5 minutes", "duration": "5 minutes",
@ -195,8 +163,6 @@
"id": "what-is-dom-shadow-dom-virtual-dom", "id": "what-is-dom-shadow-dom-virtual-dom",
"title": "DOM, Shadow DOM, Virtual DOM", "title": "DOM, Shadow DOM, Virtual DOM",
"description": "Learn what is DOM, Shadow DOM and Virtual DOM and how they work.", "description": "Learn what is DOM, Shadow DOM and Virtual DOM and how they work.",
"url": "/watch/what-is-dom-shadow-dom-virtual-dom",
"fileName": "what-is-dom-shadow-dom-virtual-dom.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "6 minutes", "duration": "6 minutes",
@ -207,8 +173,6 @@
"id": "practical-intro-to-react", "id": "practical-intro-to-react",
"title": "Practical Introduction to React", "title": "Practical Introduction to React",
"description": "Learn how to create a React Application with practical example.", "description": "Learn how to create a React Application with practical example.",
"url": "/watch/practical-intro-to-react",
"fileName": "practical-intro-to-react.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "40 minutes", "duration": "40 minutes",
@ -219,8 +183,6 @@
"id": "arrays-and-objects-in-javascript", "id": "arrays-and-objects-in-javascript",
"title": "Arrays and Objects in JavaScript", "title": "Arrays and Objects in JavaScript",
"description": "Learn how to manipulate arrays and objects in JavaScript.", "description": "Learn how to manipulate arrays and objects in JavaScript.",
"url": "/watch/arrays-and-objects-in-javascript",
"fileName": "arrays-and-objects-in-javascript.md",
"isPro": false, "isPro": false,
"authorUsername": "kamranahmedse", "authorUsername": "kamranahmedse",
"duration": "12 minutes", "duration": "12 minutes",

@ -6,8 +6,6 @@ export type VideoType = {
id: string; id: string;
title: string; title: string;
description: string; description: string;
url: string;
fileName: string;
isPro: boolean; isPro: boolean;
duration: string; duration: string;
createdAt: string; createdAt: string;

@ -69,7 +69,7 @@ export default function Home(props: HomeProps) {
href={guide.url} href={guide.url}
title={guide.title} title={guide.title}
badgeText={guide.isPro ? 'PRO' : ''} badgeText={guide.isPro ? 'PRO' : ''}
subtitle={guide.formattedUpdatedAt} subtitle={guide.formattedUpdatedAt!}
/> />
))} ))}
<DimmedMore href={'/guides'} text='View all Guides' /> <DimmedMore href={'/guides'} text='View all Guides' />
@ -87,7 +87,7 @@ export default function Home(props: HomeProps) {
{videos.map(video => ( {videos.map(video => (
<LinksListItem <LinksListItem
key={video.id} key={video.id}
href={video.url} href={`/watch/${video.id}`}
badgeText={video.isPro ? 'PRO' : ''} badgeText={video.isPro ? 'PRO' : ''}
hideSubtitleOnMobile hideSubtitleOnMobile
title={video.title} title={video.title}

@ -1,32 +0,0 @@
import { Box, Container } from '@chakra-ui/react';
import { GlobalHeader } from '../../components/global-header';
import { OpensourceBanner } from '../../components/opensource-banner';
import { UpdatesBanner } from '../../components/updates-banner';
import { Footer } from '../../components/footer';
import { ContentPageHeader } from '../../components/content-page-header';
import MdRenderer from '../../components/md-renderer';
export default function Video() {
const VideoContent = require(`../../content/videos/system-design-101.md`).default;
return (
<Box bg='white' minH='100vh'>
<GlobalHeader />
<Box mb='60px'>
<ContentPageHeader
title={'Build it and they will come?'}
subtitle={'Why “build it and they will come” alone won’t work anymore'}
/>
<Container maxW={'container.md'} position='relative'>
<MdRenderer>
<VideoContent />
</MdRenderer>
</Container>
</Box>
<OpensourceBanner />
<UpdatesBanner />
<Footer />
</Box>
);
}

@ -0,0 +1,84 @@
import { Box, Container } from '@chakra-ui/react';
import { GlobalHeader } from '../../components/global-header';
import { OpensourceBanner } from '../../components/opensource-banner';
import { UpdatesBanner } from '../../components/updates-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';
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 />
<Box mb='60px'>
<ContentPageHeader
title={video.title}
subtitle={video.description}
formattedDate={video.formattedUpdatedAt!}
subLink={{
text: 'Watch on YouTube',
url: 'https://youtube.com'
}}
author={{
twitter: video.author?.twitter!,
name: video.author?.name!,
picture: video.author?.picture!
}}
/>
<Container maxW={'container.md'} position='relative'>
<MdRenderer>
<VideoContent />
</MdRenderer>
</Container>
</Box>
<OpensourceBanner />
<UpdatesBanner />
<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;
console.log(getVideoById(videoId));
return {
props: {
video: getVideoById(videoId)
}
};
}

@ -26,7 +26,7 @@ export default function Watch(props: VideosProps) {
<SimpleGrid columns={[1, 1, 2]} mb='30px' spacing={['10px', '10px', '15px']}> <SimpleGrid columns={[1, 1, 2]} mb='30px' spacing={['10px', '10px', '15px']}>
{videos.map((video, counter) => ( {videos.map((video, counter) => (
<VideoGridItem <VideoGridItem
href={video.url} href={`/watch/${video.id}`}
key={video.id} key={video.id}
title={video.title} title={video.title}
subtitle={video.description} subtitle={video.description}

Loading…
Cancel
Save