personal-website/keystatic/content-components/ShowableFigure.tsx
2024-04-19 14:51:33 +02:00

34 lines
628 B
TypeScript

import type { PropsWithChildren } from 'react';
export interface Props {
value: {
image: {
data: Uint8Array;
extension: string;
filename: string;
} | null;
altText: string;
};
}
export default function ShowableFigureView({
value: { altText, image },
children,
}: PropsWithChildren<Props>) {
return (
<div
style={{
padding: '1rem',
}}
>
<img
style={{ marginBottom: '0.5rem' }}
src={image ? URL.createObjectURL(new Blob([image.data])) : undefined}
alt={altText}
title={altText}
/>
{children}
</div>
);
}