@nonphoto/sanity-image 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -4
- package/package.json +1 -1
- package/src/index.ts +14 -10
package/dist/index.d.ts
CHANGED
|
@@ -12,18 +12,20 @@ declare const defaultWidths: number[];
|
|
|
12
12
|
declare const lowResWidth = 24;
|
|
13
13
|
declare const defaultMetaImageWidth = 1200;
|
|
14
14
|
declare const defaultQuality = 90;
|
|
15
|
-
|
|
15
|
+
interface ImagePropsOptions {
|
|
16
16
|
client: SanityClientLike | SanityProjectDetails | SanityModernClientLike;
|
|
17
17
|
image: SanityImageSource;
|
|
18
18
|
metadata?: Metadata;
|
|
19
19
|
widths?: number[];
|
|
20
20
|
quality?: number;
|
|
21
21
|
aspectRatio?: number;
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
|
+
interface ImagePropsReturn {
|
|
23
24
|
src: string;
|
|
24
25
|
srcset?: string;
|
|
25
26
|
naturalWidth?: number;
|
|
26
27
|
naturalHeight?: number;
|
|
27
|
-
}
|
|
28
|
+
}
|
|
29
|
+
declare function imageProps({ client, image, metadata, widths, quality, aspectRatio, }: ImagePropsOptions): ImagePropsReturn;
|
|
28
30
|
|
|
29
|
-
export { type Metadata, type Size, defaultMetaImageWidth, defaultQuality, defaultWidths, imageProps, lowResWidth };
|
|
31
|
+
export { type ImagePropsOptions, type ImagePropsReturn, type Metadata, type Size, defaultMetaImageWidth, defaultQuality, defaultWidths, imageProps, lowResWidth };
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -92,26 +92,30 @@ function isCrop(x: any): x is SanityImageCrop {
|
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
export
|
|
96
|
-
client,
|
|
97
|
-
image,
|
|
98
|
-
metadata,
|
|
99
|
-
widths,
|
|
100
|
-
quality = defaultQuality,
|
|
101
|
-
aspectRatio,
|
|
102
|
-
}: {
|
|
95
|
+
export interface ImagePropsOptions {
|
|
103
96
|
client: SanityClientLike | SanityProjectDetails | SanityModernClientLike;
|
|
104
97
|
image: SanityImageSource;
|
|
105
98
|
metadata?: Metadata;
|
|
106
99
|
widths?: number[];
|
|
107
100
|
quality?: number;
|
|
108
101
|
aspectRatio?: number;
|
|
109
|
-
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface ImagePropsReturn {
|
|
110
105
|
src: string;
|
|
111
106
|
srcset?: string;
|
|
112
107
|
naturalWidth?: number;
|
|
113
108
|
naturalHeight?: number;
|
|
114
|
-
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function imageProps({
|
|
112
|
+
client,
|
|
113
|
+
image,
|
|
114
|
+
metadata,
|
|
115
|
+
widths,
|
|
116
|
+
quality = defaultQuality,
|
|
117
|
+
aspectRatio,
|
|
118
|
+
}: ImagePropsOptions): ImagePropsReturn {
|
|
115
119
|
const builder = imageUrlBuilder(client)
|
|
116
120
|
.image(image)
|
|
117
121
|
.quality(quality)
|