refactor: add a YouTubeVideo component
This commit is contained in:
parent
c91a573aaa
commit
2280ef1096
14
src/components/YouTubeVideo.astro
Normal file
14
src/components/YouTubeVideo.astro
Normal file
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
interface Props {
|
||||
id: string;
|
||||
}
|
||||
|
||||
const videoId = Astro.props.id;
|
||||
---
|
||||
|
||||
<iframe
|
||||
allowfullscreen
|
||||
class="w-full aspect-[16/9] border border-gray-500"
|
||||
frameborder="0"
|
||||
src={`https://www.youtube.com/embed/${videoId}?rel=0&iv_load_policy=3`}
|
||||
/>
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
import Markdown from '../Markdown.astro';
|
||||
import YouTubeVideo from '../YouTubeVideo.astro';
|
||||
|
||||
interface Props {
|
||||
id: string;
|
||||
|
@ -15,12 +16,7 @@ const { id, type }: Props = Astro.props;
|
|||
<h2 class="mb-2">Video</h2>
|
||||
|
||||
<div>
|
||||
<iframe
|
||||
allowfullscreen
|
||||
class="w-full aspect-[16/9]"
|
||||
frameborder="0"
|
||||
src={`https://www.youtube.com/embed/${id}?rel=0&iv_load_policy=3`}
|
||||
/>
|
||||
<YouTubeVideo id={id} />
|
||||
</div>
|
||||
</Markdown>
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue