Create basic watch page for YouTube videos
This commit is contained in:
parent
24cdb90ecf
commit
3128919705
28
src/pages/watch.astro
Normal file
28
src/pages/watch.astro
Normal file
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
// Layout
|
||||
import Base from "@layouts/Default.astro";
|
||||
|
||||
// Environment Variables
|
||||
const DEFAULT_INVIDIOUS_INSTANCE = import.meta.env.DEFAULT_INVIDIOUS_INSTANCE
|
||||
|
||||
// Components
|
||||
|
||||
// Fetch
|
||||
const SWV = Astro.url.href.split("watch?v=").pop();
|
||||
const video = await fetch('https://' + DEFAULT_INVIDIOUS_INSTANCE + "/api/v1/videos/" + SWV).then((response) => response.json());
|
||||
const comments = await fetch('https://' + DEFAULT_INVIDIOUS_INSTANCE + "/api/v1/comments/" + SWV).then((response) => response.json());
|
||||
---
|
||||
|
||||
<Base Title={video.title}>
|
||||
<div class="video-container">
|
||||
<video
|
||||
autoplay
|
||||
controls
|
||||
poster={'https://i.ytimg.com/vi/' + video.videoId + '/maxresdefault.jpg'}
|
||||
video-title={video.title}
|
||||
style="width: 100%;"
|
||||
src={'https://' + DEFAULT_INVIDIOUS_INSTANCE + '/latest_version?id=' + video.videoId}
|
||||
>
|
||||
</video>
|
||||
</div>
|
||||
</Base>
|
Reference in a new issue