WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/PrismicImage.tsx
+14-22Lines changed: 14 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ export type PrismicImageProps = Omit<
29
29
ComponentProps<"img">,
30
30
"src"|"srcset"|"alt"
31
31
>&{
32
-
/** The Prismic Image field or thumbnail to render. */
32
+
/** The Prismic image field or thumbnail to render. */
33
33
field: ImageFieldImage|null|undefined;
34
34
35
35
/**
@@ -48,7 +48,7 @@ export type PrismicImageProps = Omit<
48
48
alt?: "";
49
49
50
50
/**
51
-
* Declare an image as decorative only if the Image field does not have
51
+
* Declare an image as decorative only if the image field does not have
52
52
* alternative text by providing `fallbackAlt=""`.
53
53
*
54
54
* See:
@@ -64,13 +64,13 @@ export type PrismicImageProps = Omit<
64
64
}&(
65
65
|{
66
66
/**
67
-
* Widths used to build a `srcset` value for the Image field.
67
+
* Widths (in pixels) used to build a `srcset` value for the image
68
+
* field.
68
69
*
69
-
* If a `widths` prop is not given or `"defaults"` is passed, the
70
-
* following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,
71
-
* 3840.
70
+
* If omitted or set to `"defaults"`, the following widths will be used:
71
+
* 640, 750, 828, 1080, 1200, 1920, 2048, 3840.
72
72
*
73
-
* If the Image field contains responsive views, each responsive view
73
+
* If the image field contains responsive views, each responsive view
74
74
* can be used as a width in the resulting `srcset` by passing
75
75
* `"thumbnails"` as the `widths` prop.
76
76
*/
@@ -84,7 +84,7 @@ export type PrismicImageProps = Omit<
84
84
/** Not used when the `widths` prop is used. */
85
85
widths?: never;
86
86
/**
87
-
* Pixel densities used to build a `srcset` value for the Image field.
87
+
* Pixel densities used to build a `srcset` value for the image field.
88
88
*
89
89
* If a `pixelDensities` prop is passed `"defaults"`, the following
90
90
* pixel densities will be used: 1, 2, 3.
@@ -98,23 +98,15 @@ export type PrismicImageProps = Omit<
98
98
);
99
99
100
100
/**
101
-
* React component that renders an image from a Prismic Image field or one of
102
-
* its thumbnails. It will automatically set the `alt` attribute using the Image
103
-
* field's `alt` property.
101
+
* Renders an optimized image from a Prismic image field.
104
102
*
105
-
* By default, a widths-based srcset will be used to support responsive images.
106
-
* This ensures only the smallest image needed for a browser is downloaded.
103
+
* @example
107
104
*
108
-
* To use a pixel-density-based srcset, use the `pixelDensities` prop. Default
109
-
* pixel densities can be used by using `pixelDensities="defaults"`.
105
+
* ```tsx
106
+
* <PrismicImage field={slice.primary.photo} />;
107
+
* ```
110
108
*
111
-
* **Note**: If you are using a framework that has a native image component,
112
-
* such as Next.js and Gatsby, prefer using those image components instead. They
113
-
* can provide deeper framework integration than `<PrismicImage>`.
114
-
*
115
-
* @param props - Props for the component.
116
-
*
117
-
* @returns A responsive image component for the given Image field.
109
+
* @see Learn how to optimize images with imgix, use responsive images, and use framework-specific image components: {@link https://prismic.io/docs/fields/image}
* A function mapping Rich Text block types to React Components. It is used to
30
-
* render Rich Text or Title fields.
29
+
* A function mapping rich text block types to React Components. It is used to
30
+
* render rich text fields.
31
31
*
32
-
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
32
+
* @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
* A map of Rich Text block types to React Components. It is used to render Rich
38
-
* Text or Title fields.
37
+
* A map of rich text block types to React Components. It is used to render rich
38
+
* text fields.
39
39
*
40
-
* @see Templating Rich Text and Title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
40
+
* @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
`[PrismicText] The "field" prop only accepts a Rich Text or Title field's value but was provided a different type of field instead (e.g. a Key Text or Select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(
50
+
`[PrismicText] The "field" prop only accepts a rich text field's value but was provided a different type of field instead (e.g. a key text or select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(
0 commit comments