@prismicio/vue 3.0.0-beta.2 → 3.0.0-beta.5
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.cjs +19 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +21 -80
- package/dist/index.js +21 -24
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
- package/src/components/PrismicImage.ts +13 -6
- package/src/components/PrismicRichText.ts +1 -2
- package/src/components/PrismicText.ts +1 -2
- package/src/components/SliceZone.ts +1 -1
- package/src/createPrismic.ts +12 -28
- package/src/index.ts +0 -1
- package/src/types.ts +19 -0
|
@@ -63,7 +63,7 @@ export type PrismicImageProps = {
|
|
|
63
63
|
* coming from the API.
|
|
64
64
|
* @remarks
|
|
65
65
|
* A special value of `"defaults"` is accepted to automatically use image
|
|
66
|
-
* widths coming from
|
|
66
|
+
* widths coming from the plugin configuration.
|
|
67
67
|
* @remarks
|
|
68
68
|
* This prop is not compatible with the `pixelDensities` prop. When both are
|
|
69
69
|
* used the `pixelDensities` prop will be ignored.
|
|
@@ -78,7 +78,7 @@ export type PrismicImageProps = {
|
|
|
78
78
|
*
|
|
79
79
|
* @remarks
|
|
80
80
|
* A special value of `"defaults"` is accepted to automatically use image
|
|
81
|
-
* pixel densities coming from
|
|
81
|
+
* pixel densities coming from the plugin configuration.
|
|
82
82
|
* @remarks
|
|
83
83
|
* This prop is not compatible with the `widths` prop. When both are used, the
|
|
84
84
|
* `pixelDensities` prop will be ignored.
|
|
@@ -114,7 +114,7 @@ export type UsePrismicImageReturnType = {
|
|
|
114
114
|
/**
|
|
115
115
|
* Resolved image `alt` value.
|
|
116
116
|
*/
|
|
117
|
-
alt: ComputedRef<string
|
|
117
|
+
alt: ComputedRef<string>;
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* Resolved image `copyright` value.
|
|
@@ -132,6 +132,8 @@ export type UsePrismicImageReturnType = {
|
|
|
132
132
|
export const usePrismicImage = (
|
|
133
133
|
props: UsePrismicImageOptions,
|
|
134
134
|
): UsePrismicImageReturnType => {
|
|
135
|
+
const { options } = usePrismic();
|
|
136
|
+
|
|
135
137
|
const asImage = computed(() => {
|
|
136
138
|
const field = unref(props.field);
|
|
137
139
|
|
|
@@ -164,7 +166,10 @@ export const usePrismicImage = (
|
|
|
164
166
|
{ url, dimensions, alt, copyright },
|
|
165
167
|
{
|
|
166
168
|
...imgixParams,
|
|
167
|
-
widths:
|
|
169
|
+
widths:
|
|
170
|
+
widths === "defaults"
|
|
171
|
+
? options.components?.imageWidthSrcSetDefaults
|
|
172
|
+
: widths,
|
|
168
173
|
},
|
|
169
174
|
);
|
|
170
175
|
}
|
|
@@ -172,7 +177,9 @@ export const usePrismicImage = (
|
|
|
172
177
|
return asImagePixelDensitySrcSet(field, {
|
|
173
178
|
...imgixParams,
|
|
174
179
|
pixelDensities:
|
|
175
|
-
pixelDensities === "defaults"
|
|
180
|
+
pixelDensities === "defaults"
|
|
181
|
+
? options.components?.imagePixelDensitySrcSetDefaults
|
|
182
|
+
: pixelDensities,
|
|
176
183
|
});
|
|
177
184
|
} else {
|
|
178
185
|
return {
|
|
@@ -189,7 +196,7 @@ export const usePrismicImage = (
|
|
|
189
196
|
return asImage.value.srcset;
|
|
190
197
|
});
|
|
191
198
|
const alt = computed(() => {
|
|
192
|
-
return unref(props.field).alt ||
|
|
199
|
+
return unref(props.field).alt || "";
|
|
193
200
|
});
|
|
194
201
|
const copyright = computed(() => {
|
|
195
202
|
return unref(props.field).copyright || null;
|
|
@@ -106,8 +106,7 @@ export const usePrismicRichText = (
|
|
|
106
106
|
const htmlSerializer =
|
|
107
107
|
unref(props.htmlSerializer) ?? options.htmlSerializer;
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
return asHTML(unref(props.field), linkResolver, htmlSerializer) || "";
|
|
109
|
+
return asHTML(unref(props.field), linkResolver, htmlSerializer);
|
|
111
110
|
});
|
|
112
111
|
|
|
113
112
|
return {
|
|
@@ -74,8 +74,7 @@ export const usePrismicText = (
|
|
|
74
74
|
props: UsePrismicTextOptions,
|
|
75
75
|
): UsePrismicTextReturnType => {
|
|
76
76
|
const text = computed(() => {
|
|
77
|
-
|
|
78
|
-
return asText(unref(props.field), unref(props.separator)) || "";
|
|
77
|
+
return asText(unref(props.field), unref(props.separator));
|
|
79
78
|
});
|
|
80
79
|
|
|
81
80
|
return {
|
|
@@ -193,7 +193,7 @@ export type SliceComponentType<
|
|
|
193
193
|
export const TODOSliceComponent = __PRODUCTION__
|
|
194
194
|
? ((() => null) as FunctionalComponent<SliceComponentProps>)
|
|
195
195
|
: /*#__PURE__*/ (defineComponent({
|
|
196
|
-
name: "
|
|
196
|
+
name: "TODOSliceComponent",
|
|
197
197
|
props: getSliceComponentProps(),
|
|
198
198
|
setup(props) {
|
|
199
199
|
watchEffect(() => {
|
package/src/createPrismic.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { App } from "vue";
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
createClient,
|
|
5
|
-
getEndpoint,
|
|
6
5
|
predicate,
|
|
7
6
|
cookie,
|
|
8
7
|
Client,
|
|
@@ -51,34 +50,19 @@ export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {
|
|
|
51
50
|
if (options.client) {
|
|
52
51
|
client = options.client;
|
|
53
52
|
} else {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
client = createClient(options.endpoint, {
|
|
54
|
+
fetch: async (endpoint, options) => {
|
|
55
|
+
let fetchFunction: FetchLike;
|
|
56
|
+
if (typeof globalThis.fetch === "function") {
|
|
57
|
+
fetchFunction = globalThis.fetch;
|
|
58
|
+
} else {
|
|
59
|
+
fetchFunction = (await import("isomorphic-unfetch")).default;
|
|
60
|
+
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
)
|
|
66
|
-
client = createClient(endpoint, options.clientConfig);
|
|
67
|
-
} else {
|
|
68
|
-
client = createClient(endpoint, {
|
|
69
|
-
...options.clientConfig,
|
|
70
|
-
fetch: async (endpoint, options) => {
|
|
71
|
-
let fetchFunction: FetchLike;
|
|
72
|
-
if (typeof globalThis.fetch === "function") {
|
|
73
|
-
fetchFunction = globalThis.fetch;
|
|
74
|
-
} else {
|
|
75
|
-
fetchFunction = (await import("isomorphic-unfetch")).default;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return await fetchFunction(endpoint, options);
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
}
|
|
62
|
+
return await fetchFunction(endpoint, options);
|
|
63
|
+
},
|
|
64
|
+
...options.clientConfig,
|
|
65
|
+
});
|
|
82
66
|
}
|
|
83
67
|
|
|
84
68
|
const prismicClient: PrismicPluginClient = {
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -86,6 +86,25 @@ type PrismicPluginComponentsOptions = {
|
|
|
86
86
|
*/
|
|
87
87
|
imageComponent?: string | ConcreteComponent;
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Default widths to use when rendering an image with `widths="defaults"`
|
|
91
|
+
*
|
|
92
|
+
* @remarks
|
|
93
|
+
* Consider configuring image widths within your content type definition and
|
|
94
|
+
* using `widths="auto"` instead to give content writers the ability to crop
|
|
95
|
+
* images in the editor.
|
|
96
|
+
* @defaultValue `@prismicio/helpers` defaults
|
|
97
|
+
*/
|
|
98
|
+
imageWidthSrcSetDefaults?: number[];
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Default pixel densities to use when rendering an image with
|
|
102
|
+
* `pixel-densities="defaults"`
|
|
103
|
+
*
|
|
104
|
+
* @defaultValue `@prismicio/helpers` defaults
|
|
105
|
+
*/
|
|
106
|
+
imagePixelDensitySrcSetDefaults?: number[];
|
|
107
|
+
|
|
89
108
|
/**
|
|
90
109
|
* A component or a functional component rendered if a component mapping from
|
|
91
110
|
* the `components` prop cannot be found.
|