@prismicio/vue 3.0.0-alpha.3 → 3.0.0-beta.0
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/README.md +14 -1
- package/dist/index.cjs +84 -80
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +690 -534
- package/dist/index.mjs +72 -66
- package/dist/index.mjs.map +1 -0
- package/package.json +31 -32
- package/src/components/PrismicEmbed.ts +3 -1
- package/src/components/PrismicImage.ts +21 -35
- package/src/components/PrismicLink.ts +64 -44
- package/src/components/PrismicRichText.ts +47 -108
- package/src/components/PrismicText.ts +9 -5
- package/src/components/SliceZone.ts +151 -56
- package/src/components/index.ts +3 -1
- package/src/composables.ts +182 -95
- package/src/createPrismic.ts +3 -9
- package/src/index.ts +9 -4
- package/src/lib/__PRODUCTION__.ts +2 -1
- package/src/lib/getSlots.ts +2 -2
- package/src/lib/isInternalURL.ts +6 -2
- package/src/lib/simplyResolveComponent.ts +2 -2
- package/src/types.ts +118 -97
- package/src/usePrismic.ts +8 -9
- package/src/useStatefulPrismicClientMethod.ts +31 -17
package/src/composables.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
// Imports for @link references:
|
|
4
4
|
|
|
5
|
-
import type { Client
|
|
5
|
+
import type { Client } from "@prismicio/client";
|
|
6
6
|
|
|
7
7
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
8
8
|
|
|
9
|
-
import { PrismicDocument } from "@prismicio/types";
|
|
9
|
+
import { PrismicDocument, Query } from "@prismicio/types";
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
ClientMethodParameters,
|
|
@@ -20,14 +20,12 @@ import {
|
|
|
20
20
|
/**
|
|
21
21
|
* A composable that queries content from the Prismic repository.
|
|
22
22
|
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
25
|
+
* @typeParam TDocument - Type of Prismic documents returned
|
|
23
26
|
* @param params - Parameters to filter, sort, and paginate results
|
|
24
27
|
*
|
|
25
28
|
* @returns The composable payload {@link ClientComposableReturnType}
|
|
26
|
-
*
|
|
27
|
-
* @typeParam TDocument - Type of Prismic documents returned
|
|
28
|
-
*
|
|
29
|
-
* @remarks An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
30
|
-
*
|
|
31
29
|
* @see Underlying `@prismicio/client` method {@link Client.get}
|
|
32
30
|
*/
|
|
33
31
|
export const usePrismicDocuments = <TDocument extends PrismicDocument>(
|
|
@@ -38,16 +36,15 @@ export const usePrismicDocuments = <TDocument extends PrismicDocument>(
|
|
|
38
36
|
useStatefulPrismicClientMethod("get", args);
|
|
39
37
|
|
|
40
38
|
/**
|
|
41
|
-
* A composable that queries content from the Prismic repository and returns
|
|
39
|
+
* A composable that queries content from the Prismic repository and returns
|
|
40
|
+
* only the first result, if any.
|
|
42
41
|
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
44
|
+
* @typeParam TDocument - Type of the Prismic document returned
|
|
43
45
|
* @param params - Parameters to filter, sort, and paginate results
|
|
44
46
|
*
|
|
45
47
|
* @returns The composable payload {@link ClientComposableReturnType}
|
|
46
|
-
*
|
|
47
|
-
* @typeParam TDocument - Type of the Prismic document returned
|
|
48
|
-
*
|
|
49
|
-
* @remarks An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
50
|
-
*
|
|
51
48
|
* @see Underlying `@prismicio/client` method {@link Client.getFirst}
|
|
52
49
|
*/
|
|
53
50
|
export const useFirstPrismicDocument = <TDocument extends PrismicDocument>(
|
|
@@ -57,38 +54,16 @@ export const useFirstPrismicDocument = <TDocument extends PrismicDocument>(
|
|
|
57
54
|
): ClientComposableReturnType<TDocument> =>
|
|
58
55
|
useStatefulPrismicClientMethod("getFirst", args);
|
|
59
56
|
|
|
60
|
-
/**
|
|
61
|
-
* A composable that queries content from the Prismic repository and returns all matching content. If no predicates are provided, all documents will be fetched.
|
|
62
|
-
*
|
|
63
|
-
* @param params - Parameters to filter and sort results
|
|
64
|
-
*
|
|
65
|
-
* @returns The composable payload {@link ClientComposableReturnType}
|
|
66
|
-
*
|
|
67
|
-
* @typeParam TDocument - Type of Prismic documents returned
|
|
68
|
-
*
|
|
69
|
-
* @remarks An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
70
|
-
*
|
|
71
|
-
* @see Underlying `@prismicio/client` method {@link Client.getAll}
|
|
72
|
-
*/
|
|
73
|
-
export const useAllPrismicDocuments = <TDocument extends PrismicDocument>(
|
|
74
|
-
...args: [
|
|
75
|
-
params?: ClientMethodParameters<"getAll">[0] & ComposableOnlyParameters,
|
|
76
|
-
]
|
|
77
|
-
): ClientComposableReturnType<TDocument[]> =>
|
|
78
|
-
useStatefulPrismicClientMethod("getAll", args);
|
|
79
|
-
|
|
80
57
|
/**
|
|
81
58
|
* A composable that queries a document from the Prismic repository with a specific ID.
|
|
82
59
|
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
62
|
+
* @typeParam TDocument - Type of the Prismic document returned
|
|
83
63
|
* @param id - ID of the document
|
|
84
64
|
* @param params - Parameters to filter, sort, and paginate results
|
|
85
65
|
*
|
|
86
66
|
* @returns The composable payload {@link ClientComposableReturnType}
|
|
87
|
-
*
|
|
88
|
-
* @typeParam TDocument - Type of the Prismic document returned
|
|
89
|
-
*
|
|
90
|
-
* @remarks An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
91
|
-
*
|
|
92
67
|
* @see Underlying `@prismicio/client` method {@link Client.getByID}
|
|
93
68
|
*/
|
|
94
69
|
export const usePrismicDocumentByID = <TDocument extends PrismicDocument>(
|
|
@@ -102,15 +77,13 @@ export const usePrismicDocumentByID = <TDocument extends PrismicDocument>(
|
|
|
102
77
|
/**
|
|
103
78
|
* A composable that queries documents from the Prismic repository with specific IDs.
|
|
104
79
|
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
82
|
+
* @typeParam TDocument - Type of Prismic documents returned
|
|
105
83
|
* @param ids - A list of document IDs
|
|
106
84
|
* @param params - Parameters to filter, sort, and paginate results
|
|
107
85
|
*
|
|
108
86
|
* @returns The composable payload {@link ClientComposableReturnType}
|
|
109
|
-
*
|
|
110
|
-
* @typeParam TDocument - Type of Prismic documents returned
|
|
111
|
-
*
|
|
112
|
-
* @remarks An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
113
|
-
*
|
|
114
87
|
* @see Underlying `@prismicio/client` method {@link Client.getByIDs}
|
|
115
88
|
*/
|
|
116
89
|
export const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
|
|
@@ -124,15 +97,13 @@ export const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
|
|
|
124
97
|
/**
|
|
125
98
|
* A composable that queries all documents from the Prismic repository with specific IDs.
|
|
126
99
|
*
|
|
100
|
+
* @remarks
|
|
101
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
102
|
+
* @typeParam TDocument - Type of Prismic documents returned
|
|
127
103
|
* @param ids - A list of document IDs
|
|
128
104
|
* @param params - Parameters to filter and sort results
|
|
129
105
|
*
|
|
130
106
|
* @returns The composable payload {@link ClientComposableReturnType}
|
|
131
|
-
*
|
|
132
|
-
* @typeParam TDocument - Type of Prismic documents returned
|
|
133
|
-
*
|
|
134
|
-
* @remarks An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
135
|
-
*
|
|
136
107
|
* @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}
|
|
137
108
|
*/
|
|
138
109
|
export const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
|
|
@@ -145,18 +116,17 @@ export const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
|
|
|
145
116
|
useStatefulPrismicClientMethod("getAllByIDs", args);
|
|
146
117
|
|
|
147
118
|
/**
|
|
148
|
-
* A composable that queries a document from the Prismic repository with a
|
|
119
|
+
* A composable that queries a document from the Prismic repository with a
|
|
120
|
+
* specific UID and Custom Type.
|
|
149
121
|
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
124
|
+
* @typeParam TDocument - Type of the Prismic document returned
|
|
150
125
|
* @param documentType - The API ID of the document's Custom Type
|
|
151
126
|
* @param uid - UID of the document
|
|
152
127
|
* @param params - Parameters to filter, sort, and paginate results
|
|
153
128
|
*
|
|
154
129
|
* @returns The composable payload {@link ClientComposableReturnType}
|
|
155
|
-
*
|
|
156
|
-
* @typeParam TDocument - Type of the Prismic document returned
|
|
157
|
-
*
|
|
158
|
-
* @remarks An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
159
|
-
*
|
|
160
130
|
* @see Underlying `@prismicio/client` method {@link Client.getByUID}
|
|
161
131
|
*/
|
|
162
132
|
export const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(
|
|
@@ -169,17 +139,61 @@ export const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(
|
|
|
169
139
|
useStatefulPrismicClientMethod("getByUID", args);
|
|
170
140
|
|
|
171
141
|
/**
|
|
172
|
-
* A composable that queries
|
|
142
|
+
* A composable that queries documents from the Prismic repository with specific UIDs.
|
|
173
143
|
*
|
|
174
|
-
* @
|
|
144
|
+
* @remarks
|
|
145
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
146
|
+
* @typeParam TDocument - Type of Prismic documents returned
|
|
147
|
+
* @param documentType - The API ID of the document's Custom Type
|
|
148
|
+
* @param uids - A list of document UIDs
|
|
175
149
|
* @param params - Parameters to filter, sort, and paginate results
|
|
176
150
|
*
|
|
177
151
|
* @returns The composable payload {@link ClientComposableReturnType}
|
|
152
|
+
* @see Underlying `@prismicio/client` method {@link Client.getByIDs}
|
|
153
|
+
*/
|
|
154
|
+
export const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
|
|
155
|
+
...args: [
|
|
156
|
+
documentType: ClientMethodParameters<"getByUIDs">[0],
|
|
157
|
+
uids: ClientMethodParameters<"getByUIDs">[1],
|
|
158
|
+
params?: ClientMethodParameters<"getByUIDs">[2] & ComposableOnlyParameters,
|
|
159
|
+
]
|
|
160
|
+
): ClientComposableReturnType<Query<TDocument>> =>
|
|
161
|
+
useStatefulPrismicClientMethod("getByUIDs", args);
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* A composable that queries all documents from the Prismic repository with specific UIDs.
|
|
178
165
|
*
|
|
179
|
-
* @
|
|
166
|
+
* @remarks
|
|
167
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
168
|
+
* @typeParam TDocument - Type of Prismic documents returned
|
|
169
|
+
* @param documentType - The API ID of the document's Custom Type
|
|
170
|
+
* @param uids - A list of document UIDs
|
|
171
|
+
* @param params - Parameters to filter and sort results
|
|
172
|
+
*
|
|
173
|
+
* @returns The composable payload {@link ClientComposableReturnType}
|
|
174
|
+
* @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}
|
|
175
|
+
*/
|
|
176
|
+
export const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
|
|
177
|
+
...args: [
|
|
178
|
+
documentType: ClientMethodParameters<"getAllByUIDs">[0],
|
|
179
|
+
ids: ClientMethodParameters<"getAllByUIDs">[1],
|
|
180
|
+
params?: ClientMethodParameters<"getAllByUIDs">[2] &
|
|
181
|
+
ComposableOnlyParameters,
|
|
182
|
+
]
|
|
183
|
+
): ClientComposableReturnType<TDocument[]> =>
|
|
184
|
+
useStatefulPrismicClientMethod("getAllByUIDs", args);
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* A composable that queries a singleton document from the Prismic repository
|
|
188
|
+
* for a specific Custom Type.
|
|
180
189
|
*
|
|
181
|
-
* @remarks
|
|
190
|
+
* @remarks
|
|
191
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
192
|
+
* @typeParam TDocument - Type of the Prismic document returned
|
|
193
|
+
* @param documentType - The API ID of the singleton Custom Type
|
|
194
|
+
* @param params - Parameters to filter, sort, and paginate results
|
|
182
195
|
*
|
|
196
|
+
* @returns The composable payload {@link ClientComposableReturnType}
|
|
183
197
|
* @see Underlying `@prismicio/client` method {@link Client.getSingle}
|
|
184
198
|
*/
|
|
185
199
|
export const useSinglePrismicDocument = <TDocument extends PrismicDocument>(
|
|
@@ -191,17 +205,16 @@ export const useSinglePrismicDocument = <TDocument extends PrismicDocument>(
|
|
|
191
205
|
useStatefulPrismicClientMethod("getSingle", args);
|
|
192
206
|
|
|
193
207
|
/**
|
|
194
|
-
* A composable that queries documents from the Prismic repository for a
|
|
208
|
+
* A composable that queries documents from the Prismic repository for a
|
|
209
|
+
* specific Custom Type.
|
|
195
210
|
*
|
|
211
|
+
* @remarks
|
|
212
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
213
|
+
* @typeParam TDocument - Type of Prismic documents returned
|
|
196
214
|
* @param documentType - The API ID of the Custom Type
|
|
197
215
|
* @param params - Parameters to filter, sort, and paginate results
|
|
198
216
|
*
|
|
199
217
|
* @returns The composable payload {@link ClientComposableReturnType}
|
|
200
|
-
*
|
|
201
|
-
* @typeParam TDocument - Type of Prismic documents returned
|
|
202
|
-
*
|
|
203
|
-
* @remarks An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
204
|
-
*
|
|
205
218
|
* @see Underlying `@prismicio/client` method {@link Client.getByType}
|
|
206
219
|
*/
|
|
207
220
|
export const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(
|
|
@@ -213,17 +226,16 @@ export const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(
|
|
|
213
226
|
useStatefulPrismicClientMethod("getByType", args);
|
|
214
227
|
|
|
215
228
|
/**
|
|
216
|
-
* A composable that queries all documents from the Prismic repository for a
|
|
229
|
+
* A composable that queries all documents from the Prismic repository for a
|
|
230
|
+
* specific Custom Type.
|
|
217
231
|
*
|
|
232
|
+
* @remarks
|
|
233
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
234
|
+
* @typeParam TDocument - Type of Prismic documents returned
|
|
218
235
|
* @param documentType - The API ID of the Custom Type
|
|
219
236
|
* @param params - Parameters to filter and sort results
|
|
220
237
|
*
|
|
221
238
|
* @returns The composable payload {@link ClientComposableReturnType}
|
|
222
|
-
*
|
|
223
|
-
* @typeParam TDocument - Type of Prismic documents returned
|
|
224
|
-
*
|
|
225
|
-
* @remarks An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
226
|
-
*
|
|
227
239
|
* @see Underlying `@prismicio/client` method {@link Client.getAllByType}
|
|
228
240
|
*/
|
|
229
241
|
export const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(
|
|
@@ -238,15 +250,13 @@ export const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(
|
|
|
238
250
|
/**
|
|
239
251
|
* A composable that queries documents from the Prismic repository with a specific tag.
|
|
240
252
|
*
|
|
253
|
+
* @remarks
|
|
254
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
255
|
+
* @typeParam TDocument - Type of Prismic documents returned
|
|
241
256
|
* @param tag - The tag that must be included on a document
|
|
242
257
|
* @param params - Parameters to filter, sort, and paginate results
|
|
243
258
|
*
|
|
244
259
|
* @returns The composable payload {@link ClientComposableReturnType}
|
|
245
|
-
*
|
|
246
|
-
* @typeParam TDocument - Type of Prismic documents returned
|
|
247
|
-
*
|
|
248
|
-
* @remarks An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
249
|
-
*
|
|
250
260
|
* @see Underlying `@prismicio/client` method {@link Client.getByTag}
|
|
251
261
|
*/
|
|
252
262
|
export const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(
|
|
@@ -258,17 +268,16 @@ export const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(
|
|
|
258
268
|
useStatefulPrismicClientMethod("getByTag", args);
|
|
259
269
|
|
|
260
270
|
/**
|
|
261
|
-
* A composable that queries all documents from the Prismic repository with a
|
|
271
|
+
* A composable that queries all documents from the Prismic repository with a
|
|
272
|
+
* specific tag.
|
|
262
273
|
*
|
|
274
|
+
* @remarks
|
|
275
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
276
|
+
* @typeParam TDocument - Type of Prismic documents returned
|
|
263
277
|
* @param tag - The tag that must be included on a document
|
|
264
278
|
* @param params - Parameters to filter and sort results
|
|
265
279
|
*
|
|
266
280
|
* @returns The composable payload {@link ClientComposableReturnType}
|
|
267
|
-
*
|
|
268
|
-
* @typeParam TDocument - Type of Prismic documents returned
|
|
269
|
-
*
|
|
270
|
-
* @remarks An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
271
|
-
*
|
|
272
281
|
* @see Underlying `@prismicio/client` method {@link Client.getAllByTag}
|
|
273
282
|
*/
|
|
274
283
|
export const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(
|
|
@@ -281,46 +290,124 @@ export const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(
|
|
|
281
290
|
useStatefulPrismicClientMethod("getAllByTag", args);
|
|
282
291
|
|
|
283
292
|
/**
|
|
284
|
-
* A composable that queries documents from the Prismic repository with specific
|
|
293
|
+
* A composable that queries documents from the Prismic repository with specific
|
|
294
|
+
* tags. A document must be tagged with all of the queried tags to be included.
|
|
285
295
|
*
|
|
296
|
+
* @remarks
|
|
297
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
298
|
+
* @typeParam TDocument - Type of Prismic documents returned
|
|
286
299
|
* @param tags - A list of tags that must be included on a document
|
|
287
300
|
* @param params - Parameters to filter, sort, and paginate results
|
|
288
301
|
*
|
|
289
302
|
* @returns The composable payload {@link ClientComposableReturnType}
|
|
303
|
+
* @see Underlying `@prismicio/client` method {@link Client.getByTags}
|
|
304
|
+
*/
|
|
305
|
+
export const usePrismicDocumentsByEveryTag = <
|
|
306
|
+
TDocument extends PrismicDocument,
|
|
307
|
+
>(
|
|
308
|
+
...args: [
|
|
309
|
+
tags: ClientMethodParameters<"getByEveryTag">[0],
|
|
310
|
+
params?: ClientMethodParameters<"getByEveryTag">[1] &
|
|
311
|
+
ComposableOnlyParameters,
|
|
312
|
+
]
|
|
313
|
+
): ClientComposableReturnType<Query<TDocument>> =>
|
|
314
|
+
useStatefulPrismicClientMethod("getByEveryTag", args);
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* A composable that queries all documents from the Prismic repository with
|
|
318
|
+
* specific tags. A document must be tagged with all of the queried tags to be included.
|
|
290
319
|
*
|
|
320
|
+
* @remarks
|
|
321
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
291
322
|
* @typeParam TDocument - Type of Prismic documents returned
|
|
323
|
+
* @param tags - A list of tags that must be included on a document
|
|
324
|
+
* @param params - Parameters to filter and sort results
|
|
292
325
|
*
|
|
293
|
-
* @
|
|
326
|
+
* @returns The composable payload {@link ClientComposableReturnType}
|
|
327
|
+
* @see Underlying `@prismicio/client` method {@link Client.getAllByTags}
|
|
328
|
+
*/
|
|
329
|
+
export const useAllPrismicDocumentsByEveryTag = <
|
|
330
|
+
TDocument extends PrismicDocument,
|
|
331
|
+
>(
|
|
332
|
+
...args: [
|
|
333
|
+
tags: ClientMethodParameters<"getAllByEveryTag">[0],
|
|
334
|
+
params?: ClientMethodParameters<"getAllByEveryTag">[1] &
|
|
335
|
+
ComposableOnlyParameters,
|
|
336
|
+
]
|
|
337
|
+
): ClientComposableReturnType<TDocument[]> =>
|
|
338
|
+
useStatefulPrismicClientMethod("getAllByEveryTag", args);
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* A composable that queries documents from the Prismic repository with specific
|
|
342
|
+
* tags. A document must be tagged with at least one of the queried tags to be included.
|
|
343
|
+
*
|
|
344
|
+
* @remarks
|
|
345
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
346
|
+
* @typeParam TDocument - Type of Prismic documents returned
|
|
347
|
+
* @param tags - A list of tags that must be included on a document
|
|
348
|
+
* @param params - Parameters to filter, sort, and paginate results
|
|
294
349
|
*
|
|
350
|
+
* @returns The composable payload {@link ClientComposableReturnType}
|
|
295
351
|
* @see Underlying `@prismicio/client` method {@link Client.getByTags}
|
|
296
352
|
*/
|
|
297
|
-
export const
|
|
353
|
+
export const usePrismicDocumentsBySomeTags = <
|
|
354
|
+
TDocument extends PrismicDocument,
|
|
355
|
+
>(
|
|
298
356
|
...args: [
|
|
299
|
-
tags: ClientMethodParameters<"
|
|
300
|
-
params?: ClientMethodParameters<"
|
|
357
|
+
tags: ClientMethodParameters<"getBySomeTags">[0],
|
|
358
|
+
params?: ClientMethodParameters<"getBySomeTags">[1] &
|
|
359
|
+
ComposableOnlyParameters,
|
|
301
360
|
]
|
|
302
361
|
): ClientComposableReturnType<Query<TDocument>> =>
|
|
303
|
-
useStatefulPrismicClientMethod("
|
|
362
|
+
useStatefulPrismicClientMethod("getBySomeTags", args);
|
|
304
363
|
|
|
305
364
|
/**
|
|
306
|
-
* A composable that queries all documents from the Prismic repository with
|
|
365
|
+
* A composable that queries all documents from the Prismic repository with
|
|
366
|
+
* specific tags. A document must be tagged with at least one of the queried
|
|
367
|
+
* tags to be included.
|
|
307
368
|
*
|
|
369
|
+
* @remarks
|
|
370
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
371
|
+
* @typeParam TDocument - Type of Prismic documents returned
|
|
308
372
|
* @param tags - A list of tags that must be included on a document
|
|
309
373
|
* @param params - Parameters to filter and sort results
|
|
310
374
|
*
|
|
311
375
|
* @returns The composable payload {@link ClientComposableReturnType}
|
|
376
|
+
* @see Underlying `@prismicio/client` method {@link Client.getAllByTags}
|
|
377
|
+
*/
|
|
378
|
+
export const useAllPrismicDocumentsBySomeTags = <
|
|
379
|
+
TDocument extends PrismicDocument,
|
|
380
|
+
>(
|
|
381
|
+
...args: [
|
|
382
|
+
tags: ClientMethodParameters<"getAllBySomeTags">[0],
|
|
383
|
+
params?: ClientMethodParameters<"getAllBySomeTags">[1] &
|
|
384
|
+
ComposableOnlyParameters,
|
|
385
|
+
]
|
|
386
|
+
): ClientComposableReturnType<TDocument[]> =>
|
|
387
|
+
useStatefulPrismicClientMethod("getAllBySomeTags", args);
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* **IMPORTANT**: Avoid using `dangerouslyUseAllPrismicDocuments` as it may be
|
|
391
|
+
* slower and require more resources than other composables. Prefer using other
|
|
392
|
+
* composables that filter by predicates such as `useAllPrismicDocumentsByType`.
|
|
312
393
|
*
|
|
313
|
-
*
|
|
394
|
+
* A composable that queries content from the Prismic repository and returns all
|
|
395
|
+
* matching content. If no predicates are provided, all documents will be fetched.
|
|
314
396
|
*
|
|
315
|
-
* @remarks
|
|
397
|
+
* @remarks
|
|
398
|
+
* An additional `@prismicio/client` instance can be provided at `params.client`.
|
|
399
|
+
* @typeParam TDocument - Type of Prismic documents returned
|
|
400
|
+
* @param params - Parameters to filter and sort results
|
|
316
401
|
*
|
|
317
|
-
* @
|
|
402
|
+
* @returns The composable payload {@link ClientComposableReturnType}
|
|
403
|
+
* @see Underlying `@prismicio/client` method {@link Client.getAll}
|
|
318
404
|
*/
|
|
319
|
-
export const
|
|
405
|
+
export const dangerouslyUseAllPrismicDocuments = <
|
|
406
|
+
TDocument extends PrismicDocument,
|
|
407
|
+
>(
|
|
320
408
|
...args: [
|
|
321
|
-
|
|
322
|
-
params?: ClientMethodParameters<"getAllByTags">[1] &
|
|
409
|
+
params?: ClientMethodParameters<"dangerouslyGetAll">[0] &
|
|
323
410
|
ComposableOnlyParameters,
|
|
324
411
|
]
|
|
325
412
|
): ClientComposableReturnType<TDocument[]> =>
|
|
326
|
-
useStatefulPrismicClientMethod("
|
|
413
|
+
useStatefulPrismicClientMethod("dangerouslyGetAll", args);
|
package/src/createPrismic.ts
CHANGED
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
asLink,
|
|
15
15
|
asText,
|
|
16
16
|
documentToLinkField,
|
|
17
|
-
documentAsLink,
|
|
18
17
|
} from "@prismicio/helpers";
|
|
19
18
|
|
|
20
19
|
import {
|
|
@@ -39,7 +38,6 @@ import type {
|
|
|
39
38
|
* @param options - {@link PrismicPluginOptions}
|
|
40
39
|
*
|
|
41
40
|
* @returns `@prismicio/vue` plugin instance {@link PrismicPlugin}
|
|
42
|
-
*
|
|
43
41
|
* @see Prismic Official Vue.js documentation: {@link https://prismic.io/docs/technologies/vuejs}
|
|
44
42
|
* @see Plugin repository: {@link https://github.com/prismicio/prismic-vue}
|
|
45
43
|
*/
|
|
@@ -50,7 +48,9 @@ export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {
|
|
|
50
48
|
client = options.client;
|
|
51
49
|
} else {
|
|
52
50
|
const endpoint =
|
|
53
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* @see Regex101 expression: {@link https://regex101.com/r/GT2cl7/1}
|
|
53
|
+
*/
|
|
54
54
|
/^(https?:)?\/\//gim.test(options.endpoint)
|
|
55
55
|
? options.endpoint
|
|
56
56
|
: getEndpoint(options.endpoint);
|
|
@@ -99,12 +99,6 @@ export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {
|
|
|
99
99
|
asDate,
|
|
100
100
|
|
|
101
101
|
documentToLinkField,
|
|
102
|
-
documentAsLink: (prismicDocument, linkResolver) => {
|
|
103
|
-
return documentAsLink(
|
|
104
|
-
prismicDocument,
|
|
105
|
-
linkResolver || options.linkResolver,
|
|
106
|
-
);
|
|
107
|
-
},
|
|
108
102
|
};
|
|
109
103
|
|
|
110
104
|
// Create plugin interface
|
package/src/index.ts
CHANGED
|
@@ -15,7 +15,7 @@ export {
|
|
|
15
15
|
// Slice Zone
|
|
16
16
|
getSliceComponentProps,
|
|
17
17
|
TODOSliceComponent,
|
|
18
|
-
|
|
18
|
+
defineSliceZoneComponents,
|
|
19
19
|
SliceZoneImpl,
|
|
20
20
|
SliceZone,
|
|
21
21
|
} from "./components";
|
|
@@ -36,25 +36,30 @@ export type {
|
|
|
36
36
|
SliceComponentType,
|
|
37
37
|
SliceLike,
|
|
38
38
|
SliceZoneComponents,
|
|
39
|
+
SliceZoneResolver,
|
|
39
40
|
SliceZoneLike,
|
|
40
41
|
SliceZoneProps,
|
|
41
42
|
} from "./components";
|
|
42
43
|
|
|
43
44
|
export {
|
|
44
|
-
useAllPrismicDocuments,
|
|
45
45
|
useAllPrismicDocumentsByIDs,
|
|
46
|
+
useAllPrismicDocumentsByUIDs,
|
|
46
47
|
useAllPrismicDocumentsByTag,
|
|
47
|
-
|
|
48
|
+
useAllPrismicDocumentsByEveryTag,
|
|
49
|
+
useAllPrismicDocumentsBySomeTags,
|
|
48
50
|
useAllPrismicDocumentsByType,
|
|
49
51
|
useFirstPrismicDocument,
|
|
50
52
|
usePrismicDocumentByID,
|
|
51
53
|
usePrismicDocumentByUID,
|
|
52
54
|
usePrismicDocuments,
|
|
53
55
|
usePrismicDocumentsByIDs,
|
|
56
|
+
usePrismicDocumentsByUIDs,
|
|
54
57
|
usePrismicDocumentsByTag,
|
|
55
|
-
|
|
58
|
+
usePrismicDocumentsByEveryTag,
|
|
59
|
+
usePrismicDocumentsBySomeTags,
|
|
56
60
|
usePrismicDocumentsByType,
|
|
57
61
|
useSinglePrismicDocument,
|
|
62
|
+
dangerouslyUseAllPrismicDocuments,
|
|
58
63
|
} from "./composables";
|
|
59
64
|
|
|
60
65
|
export type { ClientComposableReturnType } from "./useStatefulPrismicClientMethod";
|
|
@@ -6,6 +6,7 @@ if (typeof process === "undefined") {
|
|
|
6
6
|
/**
|
|
7
7
|
* `true` if in the production environment, `false` otherwise.
|
|
8
8
|
*
|
|
9
|
-
* This boolean can be used to perform actions only in development environments,
|
|
9
|
+
* This boolean can be used to perform actions only in development environments,
|
|
10
|
+
* such as logging.
|
|
10
11
|
*/
|
|
11
12
|
export const __PRODUCTION__ = process.env.NODE_ENV === "production";
|
package/src/lib/getSlots.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ConcreteComponent, Slots, VNode } from "vue";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Get the appropriate `slots` object/array according to the provided parent,
|
|
4
|
+
* Get the appropriate `slots` object/array according to the provided parent,
|
|
5
|
+
* fixing `Non-function value encountered for default slot.` warnings.
|
|
5
6
|
*
|
|
6
7
|
* @param parent - The parent inheriting slots
|
|
7
8
|
* @param slots - The `slots` to transform for parent
|
|
8
9
|
* @param defaultParams - The parameters to provide to the default slot
|
|
9
10
|
*
|
|
10
11
|
* @returns The appropriate slots object/array
|
|
11
|
-
*
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
14
|
export const getSlots = (
|
package/src/lib/isInternalURL.ts
CHANGED
|
@@ -7,9 +7,13 @@
|
|
|
7
7
|
*/
|
|
8
8
|
// TODO: This does not detect all relative URLs as internal, such as `about` or `./about`. This function assumes relative URLs start with a "/"`.
|
|
9
9
|
export const isInternalURL = (url: string): boolean => {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* @see Regex101 expression: {@link https://regex101.com/r/1y7iod/1}
|
|
12
|
+
*/
|
|
11
13
|
const isInternal = /^\/(?!\/)/.test(url);
|
|
12
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* @see Regex101 expression: {@link https://regex101.com/r/RnUseS/1}
|
|
16
|
+
*/
|
|
13
17
|
const isSpecialLink = !isInternal && !/^https?:\/\//i.test(url);
|
|
14
18
|
|
|
15
19
|
return isInternal && !isSpecialLink;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ConcreteComponent, resolveDynamicComponent, VNode } from "vue";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* A stricter version of {@link resolveDynamicComponent} that resolves only type
|
|
4
|
+
* A stricter version of {@link resolveDynamicComponent} that resolves only type
|
|
5
|
+
* {@link VNode} for existing components or provided `string`.
|
|
5
6
|
*
|
|
6
7
|
* @param component - An HTML tag name, a component, or a functional component
|
|
7
8
|
*
|
|
8
9
|
* @returns Resolved component as a {@link VNode} or provided `string`.
|
|
9
|
-
*
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
12
|
export const simplyResolveComponent = (
|