import { unwrapSignalOrValue } from ':src/utils.ts' import { Ensure } from ':types' import { JSX } from 'preact' export type PictureProps = & { formats: string[] } & Ensure, 'src' | 'alt' | 'loading'> export function Picture( { formats, src, ...props }: PictureProps, ) { const groups = unwrapSignalOrValue(src)?.match(/(?.*)(?\.\w+)/) ?.groups if (groups === undefined) { throw new SyntaxError(`unable to parse path of "${src.valueOf()}"`) } const { path } = groups return ( {formats.map((format) => ( ))} ) }