mirror of
https://github.com/LukeHagar/website.git
synced 2025-12-06 04:22:07 +00:00
21 lines
530 B
Svelte
21 lines
530 B
Svelte
<script lang="ts">
|
|
export let src: string;
|
|
export let alt = "";
|
|
export let controls = true;
|
|
export let autoplay = false;
|
|
let className = "";
|
|
export { className as class };
|
|
|
|
const videoExtensions = ["mp4", "webm", "ogg"] as const;
|
|
$: isVideo = videoExtensions.some((ext) => src.endsWith(ext));
|
|
</script>
|
|
|
|
{#if isVideo}
|
|
<!-- svelte-ignore a11y-media-has-caption-->
|
|
<video {src} class={className} {controls} {autoplay}>
|
|
<slot />
|
|
</video>
|
|
{:else}
|
|
<img loading="lazy" {src} {alt} class={className} />
|
|
{/if}
|