mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Add video copmenents
This commit is contained in:
parent
cd3b3f13a2
commit
6acaee1b5a
3 changed files with 173 additions and 0 deletions
31
src/components/video/poster.astro
Normal file
31
src/components/video/poster.astro
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
const {
|
||||
video
|
||||
} = Astro.props
|
||||
|
||||
const webpSource = {
|
||||
...video.thumbnail,
|
||||
srcset: video.thumbnail.srcset.replaceAll('ytimg.com/vi/', 'ytimg.com/vi_webp/').replace(/.png|.jpg|.jpeg/g, '.webp')
|
||||
}
|
||||
|
||||
const mergedSources = {
|
||||
webp: webpSource,
|
||||
jpeg: video.thumbnail
|
||||
}
|
||||
---
|
||||
<picture>
|
||||
|
||||
{ Object.entries( mergedSources ).map( ([ key, source ]) => (
|
||||
<source
|
||||
sizes={ source.sizes }
|
||||
data-srcset={ source.srcset }
|
||||
type={ `image/${ key }` }
|
||||
>
|
||||
) ) }
|
||||
|
||||
<img
|
||||
data-src={ video.thumbnail.src }
|
||||
alt={ video.name }
|
||||
class="absolute inset-0 h-full w-full object-cover lazyload"
|
||||
>
|
||||
</picture>
|
||||
Loading…
Add table
Add a link
Reference in a new issue