www/src/components/Video.astro
Shintaro Jokagi bcb1427a79
feat(lint): add biome formatter and linter, husky and lint-staged
This commit adds the Biome formatter and linter to replace Prettier, including:

- Add biome.json config file
- Add pre-commit hook with Husky
- Configure GitHub Action to run Biome checks
- Apply Biome formatting rules to codebase
- Remove Prettier dependencies
2025-05-15 13:52:37 +12:00

33 lines
711 B
Text

---
const { src, class: className, ...rest } = Astro.props;
const type = src.split(".").pop() || "webm";
---
<video
class:list={['w-fit', className]}
data-src={src}
preload="none"
{...rest}
>
<source src="" type={`video/${type}`} />
</video>
<script>
const videos = document.querySelectorAll(
'video[data-src]',
) as NodeListOf<HTMLVideoElement>
const loadVideo = (video: HTMLVideoElement) => {
const source = video.querySelector('source')
const dataSrc = video.getAttribute('data-src')
if (dataSrc && source) {
source.src = dataSrc
video.removeAttribute('data-src')
video.load()
}
}
for (const video of videos) {
loadVideo(video)
}
</script>