@prismicio/vue 3.0.0-beta.1 → 3.0.0-beta.2

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.
@@ -3,15 +3,24 @@ import {
3
3
  ComponentCustomProps,
4
4
  computed,
5
5
  ConcreteComponent,
6
+ ComputedRef,
6
7
  defineComponent,
7
8
  h,
8
9
  PropType,
9
10
  VNodeProps,
11
+ unref,
10
12
  } from "vue";
11
13
 
12
14
  import { ImageField } from "@prismicio/types";
15
+ import {
16
+ asImageSrc,
17
+ asImageWidthSrcSet,
18
+ asImagePixelDensitySrcSet,
19
+ isFilled,
20
+ } from "@prismicio/helpers";
13
21
 
14
22
  import { usePrismic } from "../usePrismic";
23
+ import { VueUseOptions } from "../types";
15
24
  import { simplyResolveComponent } from "../lib/simplyResolveComponent";
16
25
 
17
26
  /**
@@ -33,17 +42,165 @@ export type PrismicImageProps = {
33
42
  *
34
43
  * @remarks
35
44
  * HTML tag names and components will be rendered using the `img` tag
36
- * interface (`src` and `alt` attribute). Components will also receive an
37
- * additional `copyright` props.
45
+ * interface (`src`, `srcset`, and `alt` attribute). Components will also
46
+ * receive an additional `copyright` props.
38
47
  * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `"img"` otherwise.
39
48
  */
40
49
  imageComponent?: string | ConcreteComponent;
41
50
 
42
51
  /**
43
- * A map of additional props to pass to the component used to render images
44
- * when using one.
52
+ * An object of Imgix URL API parameters.
53
+ *
54
+ * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering
55
+ */
56
+ imgixParams?: Parameters<typeof asImageSrc>[1];
57
+
58
+ /**
59
+ * Adds an additional `srcset` attribute to the image following given widths.
60
+ *
61
+ * @remarks
62
+ * A special value of `"auto"` is accepted to automatically use image widths
63
+ * coming from the API.
64
+ * @remarks
65
+ * A special value of `"defaults"` is accepted to automatically use image
66
+ * widths coming from `@prismicio/helpers`
67
+ * @remarks
68
+ * This prop is not compatible with the `pixelDensities` prop. When both are
69
+ * used the `pixelDensities` prop will be ignored.
70
+ */
71
+ widths?:
72
+ | NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"]
73
+ | "auto"
74
+ | "defaults";
75
+
76
+ /**
77
+ * Adds an additional `srcset` attribute to the image following giving pixel densities.
78
+ *
79
+ * @remarks
80
+ * A special value of `"defaults"` is accepted to automatically use image
81
+ * pixel densities coming from `@prismicio/helpers`
82
+ * @remarks
83
+ * This prop is not compatible with the `widths` prop. When both are used, the
84
+ * `pixelDensities` prop will be ignored.
85
+ */
86
+ pixelDensities?:
87
+ | NonNullable<
88
+ Parameters<typeof asImagePixelDensitySrcSet>[1]
89
+ >["pixelDensities"]
90
+ | "defaults";
91
+ };
92
+
93
+ /**
94
+ * Options for {@link usePrismicImage}.
95
+ */
96
+ export type UsePrismicImageOptions = VueUseOptions<
97
+ Omit<PrismicImageProps, "imageComponent">
98
+ >;
99
+
100
+ /**
101
+ * Return type of {@link usePrismicImage}.
102
+ */
103
+ export type UsePrismicImageReturnType = {
104
+ /**
105
+ * Resolved image `src` value.
106
+ */
107
+ src: ComputedRef<string | null>;
108
+
109
+ /**
110
+ * Resolved image `srcset` value.
111
+ */
112
+ srcset: ComputedRef<string | null>;
113
+
114
+ /**
115
+ * Resolved image `alt` value.
45
116
  */
46
- imageComponentAdditionalProps?: Record<string, unknown>;
117
+ alt: ComputedRef<string | null>;
118
+
119
+ /**
120
+ * Resolved image `copyright` value.
121
+ */
122
+ copyright: ComputedRef<string | null>;
123
+ };
124
+
125
+ /**
126
+ * A low level composable that returns a resolved information about a Prismic image field.
127
+ *
128
+ * @param props - {@link UsePrismicImageOptions}
129
+ *
130
+ * @returns - Resolved image information {@link UsePrismicImageReturnType}
131
+ */
132
+ export const usePrismicImage = (
133
+ props: UsePrismicImageOptions,
134
+ ): UsePrismicImageReturnType => {
135
+ const asImage = computed(() => {
136
+ const field = unref(props.field);
137
+
138
+ if (!isFilled.image(field)) {
139
+ return {
140
+ src: null,
141
+ srcset: null,
142
+ };
143
+ }
144
+
145
+ const imgixParams = unref(props.imgixParams);
146
+ const widths = unref(props.widths);
147
+ const pixelDensities = unref(props.pixelDensities);
148
+
149
+ if (widths) {
150
+ if (pixelDensities) {
151
+ console.warn(
152
+ "[PrismicImage] `widths` and `pixelDensities` props should not be use alongside each others, only `widths` will be applied",
153
+ props,
154
+ );
155
+ }
156
+
157
+ if (widths === "auto") {
158
+ return asImageWidthSrcSet(field, imgixParams);
159
+ } else {
160
+ // Remove potential thumbnails when using manual widths
161
+ const { url, dimensions, alt, copyright } = field;
162
+
163
+ return asImageWidthSrcSet(
164
+ { url, dimensions, alt, copyright },
165
+ {
166
+ ...imgixParams,
167
+ widths: widths === "defaults" ? undefined : widths,
168
+ },
169
+ );
170
+ }
171
+ } else if (pixelDensities) {
172
+ return asImagePixelDensitySrcSet(field, {
173
+ ...imgixParams,
174
+ pixelDensities:
175
+ pixelDensities === "defaults" ? undefined : pixelDensities,
176
+ });
177
+ } else {
178
+ return {
179
+ src: asImageSrc(field, imgixParams),
180
+ srcset: null,
181
+ };
182
+ }
183
+ });
184
+
185
+ const src = computed(() => {
186
+ return asImage.value.src;
187
+ });
188
+ const srcset = computed(() => {
189
+ return asImage.value.srcset;
190
+ });
191
+ const alt = computed(() => {
192
+ return unref(props.field).alt || null;
193
+ });
194
+ const copyright = computed(() => {
195
+ return unref(props.field).copyright || null;
196
+ });
197
+
198
+ return {
199
+ src,
200
+ srcset,
201
+ alt,
202
+ copyright,
203
+ };
47
204
  };
48
205
 
49
206
  /**
@@ -63,8 +220,27 @@ export const PrismicImageImpl = /*#__PURE__*/ defineComponent({
63
220
  default: undefined,
64
221
  required: false,
65
222
  },
66
- imageComponentAdditionalProps: {
67
- type: Object as PropType<Record<string, unknown>>,
223
+ imgixParams: {
224
+ type: Object as PropType<Parameters<typeof asImageSrc>[1]>,
225
+ default: undefined,
226
+ required: false,
227
+ },
228
+ widths: {
229
+ type: [String, Object] as PropType<
230
+ | NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"]
231
+ | "auto"
232
+ | "defaults"
233
+ >,
234
+ default: undefined,
235
+ required: false,
236
+ },
237
+ pixelDensities: {
238
+ type: [String, Object] as PropType<
239
+ | NonNullable<
240
+ Parameters<typeof asImagePixelDensitySrcSet>[1]
241
+ >["pixelDensities"]
242
+ | "defaults"
243
+ >,
68
244
  default: undefined,
69
245
  required: false,
70
246
  },
@@ -85,10 +261,13 @@ export const PrismicImageImpl = /*#__PURE__*/ defineComponent({
85
261
  );
86
262
  });
87
263
 
264
+ const { src, srcset, alt, copyright } = usePrismicImage(props);
265
+
88
266
  return () => {
89
267
  const attributes = {
90
- src: props.field.url || null,
91
- alt: props.field.alt || null,
268
+ src: src.value,
269
+ srcset: srcset.value,
270
+ alt: alt.value,
92
271
  };
93
272
 
94
273
  switch (type.value) {
@@ -99,8 +278,7 @@ export const PrismicImageImpl = /*#__PURE__*/ defineComponent({
99
278
  default:
100
279
  return h(simplyResolveComponent(type.value), {
101
280
  ...attributes,
102
- copyright: props.field.copyright || null,
103
- ...props.imageComponentAdditionalProps,
281
+ copyright: copyright.value,
104
282
  });
105
283
  }
106
284
  };
@@ -50,6 +50,7 @@ export type PrismicLinkProps = {
50
50
  * resolver parameter with `@prismicio/client`.
51
51
  *
52
52
  * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.
53
+ *
53
54
  * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}
54
55
  */
55
56
  linkResolver?: LinkResolverFunction;
@@ -50,6 +50,7 @@ export type PrismicRichTextProps = {
50
50
  * resolver parameter with `@prismicio/client`.
51
51
  *
52
52
  * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.
53
+ *
53
54
  * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}
54
55
  */
55
56
  linkResolver?: LinkResolverFunction;
@@ -58,6 +59,7 @@ export type PrismicRichTextProps = {
58
59
  * An HTML serializer to customize the way rich text fields are rendered.
59
60
  *
60
61
  * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.
62
+ *
61
63
  * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}
62
64
  */
63
65
  htmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;
@@ -104,7 +106,8 @@ export const usePrismicRichText = (
104
106
  const htmlSerializer =
105
107
  unref(props.htmlSerializer) ?? options.htmlSerializer;
106
108
 
107
- return asHTML(unref(props.field), linkResolver, htmlSerializer);
109
+ // TODO: Update after https://github.com/prismicio/prismic-helpers/pull/43
110
+ return asHTML(unref(props.field), linkResolver, htmlSerializer) || "";
108
111
  });
109
112
 
110
113
  return {
@@ -22,7 +22,6 @@ import { simplyResolveComponent } from "../lib/simplyResolveComponent";
22
22
  * The default component rendered to wrap the text output.
23
23
  */
24
24
  const defaultWrapper = "div";
25
-
26
25
  /**
27
26
  * Props for `<PrismicText />`.
28
27
  */
@@ -75,7 +74,8 @@ export const usePrismicText = (
75
74
  props: UsePrismicTextOptions,
76
75
  ): UsePrismicTextReturnType => {
77
76
  const text = computed(() => {
78
- return asText(unref(props.field), unref(props.separator));
77
+ // TODO: Update after https://github.com/prismicio/prismic-helpers/pull/43
78
+ return asText(unref(props.field), unref(props.separator)) || "";
79
79
  });
80
80
 
81
81
  return {
@@ -149,7 +149,7 @@ export const getSliceComponentProps = <
149
149
  TContext = unknown,
150
150
  >(
151
151
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
152
- propsHint?: string[],
152
+ propsHint?: ["slice", "index", "slices", "context"],
153
153
  ): DefineComponentSliceComponentProps<TSlice, TContext> => ({
154
154
  slice: {
155
155
  type: Object as PropType<SliceComponentProps<TSlice, TContext>["slice"]>,
@@ -271,6 +271,7 @@ export type SliceZoneComponents<
271
271
  *
272
272
  * @typeParam TSlice - The type(s) of slices in the Slice Zone
273
273
  * @typeParam TContext - Arbitrary data made available to all Slice components
274
+ *
274
275
  * @param components - {@link SliceZoneComponents}
275
276
  *
276
277
  * @returns A new optimized record of {@link SliceZoneComponents}
@@ -326,6 +327,7 @@ export type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {
326
327
  * the `components` or `defaultComponent` props to determine the rendered component.
327
328
  *
328
329
  * @deprecated Use the `components` prop instead.
330
+ *
329
331
  * @param args - Arguments for the resolver function.
330
332
  *
331
333
  * @returns The Vue component to render for a Slice.
@@ -362,6 +364,7 @@ export type SliceZoneProps<
362
364
  * Slice Zone.
363
365
  *
364
366
  * @deprecated Use the `components` prop instead.
367
+ *
365
368
  * @param args - Arguments for the resolver function.
366
369
  *
367
370
  * @returns The Vue component to render for a Slice.
@@ -379,6 +382,7 @@ export type SliceZoneProps<
379
382
  *
380
383
  * @remarks
381
384
  * Components will be rendered using the {@link SliceComponentProps} interface.
385
+ *
382
386
  * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === "production"` else {@link TODOSliceComponent}.
383
387
  */
384
388
  defaultComponent?: SliceComponentType<TSlice, TContext>;
@@ -1,8 +1,12 @@
1
1
  export { PrismicEmbedImpl, PrismicEmbed } from "./PrismicEmbed";
2
2
  export type { PrismicEmbedProps } from "./PrismicEmbed";
3
3
 
4
- export { PrismicImageImpl, PrismicImage } from "./PrismicImage";
5
- export type { PrismicImageProps } from "./PrismicImage";
4
+ export {
5
+ usePrismicImage,
6
+ PrismicImageImpl,
7
+ PrismicImage,
8
+ } from "./PrismicImage";
9
+ export type { UsePrismicImageOptions, PrismicImageProps } from "./PrismicImage";
6
10
 
7
11
  export { usePrismicLink, PrismicLinkImpl, PrismicLink } from "./PrismicLink";
8
12
  export type { UsePrismicLinkOptions, PrismicLinkProps } from "./PrismicLink";
@@ -22,10 +22,13 @@ import {
22
22
  *
23
23
  * @remarks
24
24
  * An additional `@prismicio/client` instance can be provided at `params.client`.
25
+ *
25
26
  * @typeParam TDocument - Type of Prismic documents returned
27
+ *
26
28
  * @param params - Parameters to filter, sort, and paginate results
27
29
  *
28
30
  * @returns The composable payload {@link ClientComposableReturnType}
31
+ *
29
32
  * @see Underlying `@prismicio/client` method {@link Client.get}
30
33
  */
31
34
  export const usePrismicDocuments = <TDocument extends PrismicDocument>(
@@ -41,10 +44,13 @@ export const usePrismicDocuments = <TDocument extends PrismicDocument>(
41
44
  *
42
45
  * @remarks
43
46
  * An additional `@prismicio/client` instance can be provided at `params.client`.
47
+ *
44
48
  * @typeParam TDocument - Type of the Prismic document returned
49
+ *
45
50
  * @param params - Parameters to filter, sort, and paginate results
46
51
  *
47
52
  * @returns The composable payload {@link ClientComposableReturnType}
53
+ *
48
54
  * @see Underlying `@prismicio/client` method {@link Client.getFirst}
49
55
  */
50
56
  export const useFirstPrismicDocument = <TDocument extends PrismicDocument>(
@@ -59,11 +65,14 @@ export const useFirstPrismicDocument = <TDocument extends PrismicDocument>(
59
65
  *
60
66
  * @remarks
61
67
  * An additional `@prismicio/client` instance can be provided at `params.client`.
68
+ *
62
69
  * @typeParam TDocument - Type of the Prismic document returned
70
+ *
63
71
  * @param id - ID of the document
64
72
  * @param params - Parameters to filter, sort, and paginate results
65
73
  *
66
74
  * @returns The composable payload {@link ClientComposableReturnType}
75
+ *
67
76
  * @see Underlying `@prismicio/client` method {@link Client.getByID}
68
77
  */
69
78
  export const usePrismicDocumentByID = <TDocument extends PrismicDocument>(
@@ -79,11 +88,14 @@ export const usePrismicDocumentByID = <TDocument extends PrismicDocument>(
79
88
  *
80
89
  * @remarks
81
90
  * An additional `@prismicio/client` instance can be provided at `params.client`.
91
+ *
82
92
  * @typeParam TDocument - Type of Prismic documents returned
93
+ *
83
94
  * @param ids - A list of document IDs
84
95
  * @param params - Parameters to filter, sort, and paginate results
85
96
  *
86
97
  * @returns The composable payload {@link ClientComposableReturnType}
98
+ *
87
99
  * @see Underlying `@prismicio/client` method {@link Client.getByIDs}
88
100
  */
89
101
  export const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
@@ -99,11 +111,14 @@ export const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
99
111
  *
100
112
  * @remarks
101
113
  * An additional `@prismicio/client` instance can be provided at `params.client`.
114
+ *
102
115
  * @typeParam TDocument - Type of Prismic documents returned
116
+ *
103
117
  * @param ids - A list of document IDs
104
118
  * @param params - Parameters to filter and sort results
105
119
  *
106
120
  * @returns The composable payload {@link ClientComposableReturnType}
121
+ *
107
122
  * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}
108
123
  */
109
124
  export const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
@@ -121,12 +136,15 @@ export const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
121
136
  *
122
137
  * @remarks
123
138
  * An additional `@prismicio/client` instance can be provided at `params.client`.
139
+ *
124
140
  * @typeParam TDocument - Type of the Prismic document returned
141
+ *
125
142
  * @param documentType - The API ID of the document's Custom Type
126
143
  * @param uid - UID of the document
127
144
  * @param params - Parameters to filter, sort, and paginate results
128
145
  *
129
146
  * @returns The composable payload {@link ClientComposableReturnType}
147
+ *
130
148
  * @see Underlying `@prismicio/client` method {@link Client.getByUID}
131
149
  */
132
150
  export const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(
@@ -143,12 +161,15 @@ export const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(
143
161
  *
144
162
  * @remarks
145
163
  * An additional `@prismicio/client` instance can be provided at `params.client`.
164
+ *
146
165
  * @typeParam TDocument - Type of Prismic documents returned
166
+ *
147
167
  * @param documentType - The API ID of the document's Custom Type
148
168
  * @param uids - A list of document UIDs
149
169
  * @param params - Parameters to filter, sort, and paginate results
150
170
  *
151
171
  * @returns The composable payload {@link ClientComposableReturnType}
172
+ *
152
173
  * @see Underlying `@prismicio/client` method {@link Client.getByIDs}
153
174
  */
154
175
  export const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
@@ -165,12 +186,15 @@ export const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
165
186
  *
166
187
  * @remarks
167
188
  * An additional `@prismicio/client` instance can be provided at `params.client`.
189
+ *
168
190
  * @typeParam TDocument - Type of Prismic documents returned
191
+ *
169
192
  * @param documentType - The API ID of the document's Custom Type
170
193
  * @param uids - A list of document UIDs
171
194
  * @param params - Parameters to filter and sort results
172
195
  *
173
196
  * @returns The composable payload {@link ClientComposableReturnType}
197
+ *
174
198
  * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}
175
199
  */
176
200
  export const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
@@ -189,11 +213,14 @@ export const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
189
213
  *
190
214
  * @remarks
191
215
  * An additional `@prismicio/client` instance can be provided at `params.client`.
216
+ *
192
217
  * @typeParam TDocument - Type of the Prismic document returned
218
+ *
193
219
  * @param documentType - The API ID of the singleton Custom Type
194
220
  * @param params - Parameters to filter, sort, and paginate results
195
221
  *
196
222
  * @returns The composable payload {@link ClientComposableReturnType}
223
+ *
197
224
  * @see Underlying `@prismicio/client` method {@link Client.getSingle}
198
225
  */
199
226
  export const useSinglePrismicDocument = <TDocument extends PrismicDocument>(
@@ -210,11 +237,14 @@ export const useSinglePrismicDocument = <TDocument extends PrismicDocument>(
210
237
  *
211
238
  * @remarks
212
239
  * An additional `@prismicio/client` instance can be provided at `params.client`.
240
+ *
213
241
  * @typeParam TDocument - Type of Prismic documents returned
242
+ *
214
243
  * @param documentType - The API ID of the Custom Type
215
244
  * @param params - Parameters to filter, sort, and paginate results
216
245
  *
217
246
  * @returns The composable payload {@link ClientComposableReturnType}
247
+ *
218
248
  * @see Underlying `@prismicio/client` method {@link Client.getByType}
219
249
  */
220
250
  export const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(
@@ -231,11 +261,14 @@ export const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(
231
261
  *
232
262
  * @remarks
233
263
  * An additional `@prismicio/client` instance can be provided at `params.client`.
264
+ *
234
265
  * @typeParam TDocument - Type of Prismic documents returned
266
+ *
235
267
  * @param documentType - The API ID of the Custom Type
236
268
  * @param params - Parameters to filter and sort results
237
269
  *
238
270
  * @returns The composable payload {@link ClientComposableReturnType}
271
+ *
239
272
  * @see Underlying `@prismicio/client` method {@link Client.getAllByType}
240
273
  */
241
274
  export const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(
@@ -252,11 +285,14 @@ export const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(
252
285
  *
253
286
  * @remarks
254
287
  * An additional `@prismicio/client` instance can be provided at `params.client`.
288
+ *
255
289
  * @typeParam TDocument - Type of Prismic documents returned
290
+ *
256
291
  * @param tag - The tag that must be included on a document
257
292
  * @param params - Parameters to filter, sort, and paginate results
258
293
  *
259
294
  * @returns The composable payload {@link ClientComposableReturnType}
295
+ *
260
296
  * @see Underlying `@prismicio/client` method {@link Client.getByTag}
261
297
  */
262
298
  export const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(
@@ -273,11 +309,14 @@ export const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(
273
309
  *
274
310
  * @remarks
275
311
  * An additional `@prismicio/client` instance can be provided at `params.client`.
312
+ *
276
313
  * @typeParam TDocument - Type of Prismic documents returned
314
+ *
277
315
  * @param tag - The tag that must be included on a document
278
316
  * @param params - Parameters to filter and sort results
279
317
  *
280
318
  * @returns The composable payload {@link ClientComposableReturnType}
319
+ *
281
320
  * @see Underlying `@prismicio/client` method {@link Client.getAllByTag}
282
321
  */
283
322
  export const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(
@@ -295,11 +334,14 @@ export const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(
295
334
  *
296
335
  * @remarks
297
336
  * An additional `@prismicio/client` instance can be provided at `params.client`.
337
+ *
298
338
  * @typeParam TDocument - Type of Prismic documents returned
339
+ *
299
340
  * @param tags - A list of tags that must be included on a document
300
341
  * @param params - Parameters to filter, sort, and paginate results
301
342
  *
302
343
  * @returns The composable payload {@link ClientComposableReturnType}
344
+ *
303
345
  * @see Underlying `@prismicio/client` method {@link Client.getByTags}
304
346
  */
305
347
  export const usePrismicDocumentsByEveryTag = <
@@ -319,11 +361,14 @@ export const usePrismicDocumentsByEveryTag = <
319
361
  *
320
362
  * @remarks
321
363
  * An additional `@prismicio/client` instance can be provided at `params.client`.
364
+ *
322
365
  * @typeParam TDocument - Type of Prismic documents returned
366
+ *
323
367
  * @param tags - A list of tags that must be included on a document
324
368
  * @param params - Parameters to filter and sort results
325
369
  *
326
370
  * @returns The composable payload {@link ClientComposableReturnType}
371
+ *
327
372
  * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}
328
373
  */
329
374
  export const useAllPrismicDocumentsByEveryTag = <
@@ -343,11 +388,14 @@ export const useAllPrismicDocumentsByEveryTag = <
343
388
  *
344
389
  * @remarks
345
390
  * An additional `@prismicio/client` instance can be provided at `params.client`.
391
+ *
346
392
  * @typeParam TDocument - Type of Prismic documents returned
393
+ *
347
394
  * @param tags - A list of tags that must be included on a document
348
395
  * @param params - Parameters to filter, sort, and paginate results
349
396
  *
350
397
  * @returns The composable payload {@link ClientComposableReturnType}
398
+ *
351
399
  * @see Underlying `@prismicio/client` method {@link Client.getByTags}
352
400
  */
353
401
  export const usePrismicDocumentsBySomeTags = <
@@ -368,11 +416,14 @@ export const usePrismicDocumentsBySomeTags = <
368
416
  *
369
417
  * @remarks
370
418
  * An additional `@prismicio/client` instance can be provided at `params.client`.
419
+ *
371
420
  * @typeParam TDocument - Type of Prismic documents returned
421
+ *
372
422
  * @param tags - A list of tags that must be included on a document
373
423
  * @param params - Parameters to filter and sort results
374
424
  *
375
425
  * @returns The composable payload {@link ClientComposableReturnType}
426
+ *
376
427
  * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}
377
428
  */
378
429
  export const useAllPrismicDocumentsBySomeTags = <
@@ -396,10 +447,13 @@ export const useAllPrismicDocumentsBySomeTags = <
396
447
  *
397
448
  * @remarks
398
449
  * An additional `@prismicio/client` instance can be provided at `params.client`.
450
+ *
399
451
  * @typeParam TDocument - Type of Prismic documents returned
452
+ *
400
453
  * @param params - Parameters to filter and sort results
401
454
  *
402
455
  * @returns The composable payload {@link ClientComposableReturnType}
456
+ *
403
457
  * @see Underlying `@prismicio/client` method {@link Client.getAll}
404
458
  */
405
459
  export const dangerouslyUseAllPrismicDocuments = <
@@ -9,10 +9,13 @@ import {
9
9
  FetchLike,
10
10
  } from "@prismicio/client";
11
11
  import {
12
- asDate,
12
+ asText,
13
13
  asHTML,
14
14
  asLink,
15
- asText,
15
+ asDate,
16
+ asImageSrc,
17
+ asImageWidthSrcSet,
18
+ asImagePixelDensitySrcSet,
16
19
  documentToLinkField,
17
20
  } from "@prismicio/helpers";
18
21
 
@@ -38,6 +41,7 @@ import type {
38
41
  * @param options - {@link PrismicPluginOptions}
39
42
  *
40
43
  * @returns `@prismicio/vue` plugin instance {@link PrismicPlugin}
44
+ *
41
45
  * @see Prismic Official Vue.js documentation: {@link https://prismic.io/docs/technologies/vuejs}
42
46
  * @see Plugin repository: {@link https://github.com/prismicio/prismic-vue}
43
47
  */
@@ -97,7 +101,9 @@ export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {
97
101
  return asLink(linkField, linkResolver || options.linkResolver);
98
102
  },
99
103
  asDate,
100
-
104
+ asImageSrc,
105
+ asImageWidthSrcSet,
106
+ asImagePixelDensitySrcSet,
101
107
  documentToLinkField,
102
108
  };
103
109
 
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ export { usePrismic } from "./usePrismic";
3
3
 
4
4
  export {
5
5
  // Composables
6
+ usePrismicImage,
6
7
  usePrismicLink,
7
8
  usePrismicText,
8
9
  usePrismicRichText,
@@ -21,6 +22,7 @@ export {
21
22
  } from "./components";
22
23
  export type {
23
24
  // Composables
25
+ UsePrismicImageOptions,
24
26
  UsePrismicLinkOptions,
25
27
  UsePrismicTextOptions,
26
28
  UsePrismicRichTextOptions,
@@ -9,6 +9,7 @@ import { ConcreteComponent, Slots, VNode } from "vue";
9
9
  * @param defaultParams - The parameters to provide to the default slot
10
10
  *
11
11
  * @returns The appropriate slots object/array
12
+ *
12
13
  * @internal
13
14
  */
14
15
  export const getSlots = (
@@ -7,6 +7,7 @@ import { ConcreteComponent, resolveDynamicComponent, VNode } from "vue";
7
7
  * @param component - An HTML tag name, a component, or a functional component
8
8
  *
9
9
  * @returns Resolved component as a {@link VNode} or provided `string`.
10
+ *
10
11
  * @internal
11
12
  */
12
13
  export const simplyResolveComponent = (