mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Use poster component for cards
This commit is contained in:
parent
7b004ea590
commit
f7d7c7266f
3 changed files with 37 additions and 42 deletions
32
components-eleventy/video/poster.js
Normal file
32
components-eleventy/video/poster.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
|
||||
export default function ( video ) {
|
||||
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
|
||||
}
|
||||
|
||||
return /* html */`
|
||||
<picture>
|
||||
|
||||
${ Object.entries( mergedSources ).map( ([ key, source ]) => (/* html */`
|
||||
<source
|
||||
sizes="${ source.sizes }"
|
||||
data-srcset="${ source.srcset }"
|
||||
type="image/${ key }"
|
||||
>
|
||||
`) ).join('') }
|
||||
|
||||
<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