From 280c2b8623e0b3da134ac64b6bc3a66e2f1d71c6 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Mon, 2 Jan 2023 20:36:04 +0400 Subject: [PATCH] Add video detail page --- src/components/VideoHeader.astro | 36 ++++++++++++++++++++++++++++++++ src/pages/videos/[videoId].astro | 32 ++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 src/components/VideoHeader.astro create mode 100644 src/pages/videos/[videoId].astro diff --git a/src/components/VideoHeader.astro b/src/components/VideoHeader.astro new file mode 100644 index 000000000..e6efc49f1 --- /dev/null +++ b/src/components/VideoHeader.astro @@ -0,0 +1,36 @@ +--- +import type { VideoFileType } from '../lib/video'; + +export interface Props { + video: VideoFileType; +} + +const { video } = Astro.props; +const { frontmatter } = video; +const { author } = frontmatter; +--- + +
+
+ +

+ {frontmatter.title} +

+ +
+
diff --git a/src/pages/videos/[videoId].astro b/src/pages/videos/[videoId].astro new file mode 100644 index 000000000..47cde47fe --- /dev/null +++ b/src/pages/videos/[videoId].astro @@ -0,0 +1,32 @@ +--- +import VideoHeader from '../../components/VideoHeader.astro'; +import BaseLayout from '../../layouts/BaseLayout.astro'; +import { getAllVideos, VideoFileType } from '../../lib/video'; +import '../../styles/prism.css'; + +export interface Props { + video: VideoFileType; +} + +export async function getStaticPaths() { + const videos = await getAllVideos(); + + return videos.map((video) => ({ + params: { videoId: video.id }, + props: { video }, + })); +} + +const { videoId } = Astro.params; +const { video } = Astro.props; +--- + + + + +
+
+ +
+
+