29 lines
846 B
TypeScript
29 lines
846 B
TypeScript
import { getS3Uri, s3Client } from "@/app/utils/database.ts";
|
|
import {
|
|
createResponsiveImageClient,
|
|
type MediaProps,
|
|
preparePictureFromSharp,
|
|
} from "@bureaudouble/outils/image.ts";
|
|
|
|
export const sharp = await createResponsiveImageClient({
|
|
defaultResizes: [480, 720],
|
|
sharpUrl: "https://sharp.fuckingtech.ch/api/transformer",
|
|
s3PublicUrl: getS3Uri().href,
|
|
s3Client,
|
|
});
|
|
|
|
export const preparePicture = (props: MediaProps) =>
|
|
preparePictureFromSharp(sharp, props);
|
|
|
|
export const Image: React.FC<MediaProps> = (props) => {
|
|
const picture = preparePicture(props);
|
|
if (!picture) return null;
|
|
return (
|
|
<picture className="contents">
|
|
{picture.sources.map((source) => (
|
|
<source className="hidden" {...source} key={source.key} />
|
|
))}
|
|
<img {...picture.img} alt={picture.img.alt} />
|
|
</picture>
|
|
);
|
|
};
|