- types, generateImageSources, BlurPlaceholder, useImageFormatSupport - OptimizedImage, OptimizedImageSkeleton, useImagePreloader, ResponsiveImage - Stories: Default, WithPlaceholder, ErrorState, Loading (skeleton) - Re-export from optimized-image.tsx; tests adapted to loading state Co-authored-by: Cursor <cursoragent@cursor.com>
20 lines
441 B
TypeScript
20 lines
441 B
TypeScript
import { SUPPORTED_FORMATS } from './types';
|
|
|
|
export interface ImageSource {
|
|
src: string;
|
|
type: string;
|
|
sizes: string;
|
|
}
|
|
|
|
export function generateImageSources(
|
|
src: string,
|
|
sizes?: string,
|
|
): ImageSource[] {
|
|
const baseUrl = src.replace(/\.[^/.]+$/, '');
|
|
const sizesVal = sizes ?? '100vw';
|
|
return SUPPORTED_FORMATS.map((format) => ({
|
|
src: `${baseUrl}.${format}`,
|
|
type: `image/${format}`,
|
|
sizes: sizesVal,
|
|
}));
|
|
}
|