@wix/blog 1.0.691 → 1.0.693
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/_sdk-exports/context-blog-feed-context-provider/runtime.d.ts +664 -0
- package/_sdk-exports/context-blog-feed-context-provider/runtime.js +5 -0
- package/_sdk-exports/context-category-item-context-provider/runtime.d.ts +188 -0
- package/_sdk-exports/context-category-item-context-provider/runtime.js +2 -0
- package/_sdk-exports/context-post-by-id-context-provider/runtime.d.ts +31 -0
- package/_sdk-exports/context-post-by-id-context-provider/runtime.js +5 -0
- package/_sdk-exports/context-post-context-provider/runtime.d.ts +3389 -0
- package/_sdk-exports/context-post-context-provider/runtime.js +5 -0
- package/_sdk-exports/context-post-item-context-provider/runtime.d.ts +509 -0
- package/_sdk-exports/context-post-item-context-provider/runtime.js +5 -0
- package/_sdk-exports/context-related-posts-context-provider/runtime.d.ts +437 -0
- package/_sdk-exports/context-related-posts-context-provider/runtime.js +5 -0
- package/_sdk-exports/context-tag-item-context-provider/runtime.d.ts +186 -0
- package/_sdk-exports/context-tag-item-context-provider/runtime.js +2 -0
- package/blog-feed-context-provider/package.json +3 -0
- package/build/cjs/context-blog-feed-context-provider.d.ts +664 -0
- package/build/cjs/context-blog-feed-context-provider.js +4601 -0
- package/build/cjs/context-blog-feed-context-provider.js.map +1 -0
- package/build/cjs/context-category-item-context-provider.d.ts +188 -0
- package/build/cjs/context-category-item-context-provider.js +578 -0
- package/build/cjs/context-category-item-context-provider.js.map +1 -0
- package/build/cjs/context-post-by-id-context-provider.d.ts +31 -0
- package/build/cjs/context-post-by-id-context-provider.js +4531 -0
- package/build/cjs/context-post-by-id-context-provider.js.map +1 -0
- package/build/cjs/context-post-context-provider.d.ts +3389 -0
- package/build/cjs/context-post-context-provider.js +5404 -0
- package/build/cjs/context-post-context-provider.js.map +1 -0
- package/build/cjs/context-post-item-context-provider.d.ts +509 -0
- package/build/cjs/context-post-item-context-provider.js +3682 -0
- package/build/cjs/context-post-item-context-provider.js.map +1 -0
- package/build/cjs/context-related-posts-context-provider.d.ts +437 -0
- package/build/cjs/context-related-posts-context-provider.js +4355 -0
- package/build/cjs/context-related-posts-context-provider.js.map +1 -0
- package/build/cjs/context-tag-item-context-provider.d.ts +186 -0
- package/build/cjs/context-tag-item-context-provider.js +578 -0
- package/build/cjs/context-tag-item-context-provider.js.map +1 -0
- package/build/es/context-blog-feed-context-provider.d.mts +664 -0
- package/build/es/context-blog-feed-context-provider.mjs +4571 -0
- package/build/es/context-blog-feed-context-provider.mjs.map +1 -0
- package/build/es/context-category-item-context-provider.d.mts +188 -0
- package/build/es/context-category-item-context-provider.mjs +549 -0
- package/build/es/context-category-item-context-provider.mjs.map +1 -0
- package/build/es/context-post-by-id-context-provider.d.mts +31 -0
- package/build/es/context-post-by-id-context-provider.mjs +4491 -0
- package/build/es/context-post-by-id-context-provider.mjs.map +1 -0
- package/build/es/context-post-context-provider.d.mts +3389 -0
- package/build/es/context-post-context-provider.mjs +5374 -0
- package/build/es/context-post-context-provider.mjs.map +1 -0
- package/build/es/context-post-item-context-provider.d.mts +509 -0
- package/build/es/context-post-item-context-provider.mjs +3652 -0
- package/build/es/context-post-item-context-provider.mjs.map +1 -0
- package/build/es/context-related-posts-context-provider.d.mts +437 -0
- package/build/es/context-related-posts-context-provider.mjs +4325 -0
- package/build/es/context-related-posts-context-provider.mjs.map +1 -0
- package/build/es/context-tag-item-context-provider.d.mts +186 -0
- package/build/es/context-tag-item-context-provider.mjs +549 -0
- package/build/es/context-tag-item-context-provider.mjs.map +1 -0
- package/build/internal/cjs/context-blog-feed-context-provider.d.ts +664 -0
- package/build/internal/cjs/context-category-item-context-provider.d.ts +188 -0
- package/build/internal/cjs/context-post-by-id-context-provider.d.ts +31 -0
- package/build/internal/cjs/context-post-context-provider.d.ts +3389 -0
- package/build/internal/cjs/context-post-item-context-provider.d.ts +509 -0
- package/build/internal/cjs/context-related-posts-context-provider.d.ts +437 -0
- package/build/internal/cjs/context-tag-item-context-provider.d.ts +186 -0
- package/build/internal/es/context-blog-feed-context-provider.d.mts +664 -0
- package/build/internal/es/context-category-item-context-provider.d.mts +188 -0
- package/build/internal/es/context-post-by-id-context-provider.d.mts +31 -0
- package/build/internal/es/context-post-context-provider.d.mts +3389 -0
- package/build/internal/es/context-post-item-context-provider.d.mts +509 -0
- package/build/internal/es/context-related-posts-context-provider.d.mts +437 -0
- package/build/internal/es/context-tag-item-context-provider.d.mts +186 -0
- package/category-item-context-provider/package.json +3 -0
- package/context/blog-feed-context-provider/package.json +3 -0
- package/context/category-item-context-provider/package.json +3 -0
- package/context/post-by-id-context-provider/package.json +3 -0
- package/context/post-context-provider/package.json +3 -0
- package/context/post-item-context-provider/package.json +3 -0
- package/context/related-posts-context-provider/package.json +3 -0
- package/context/tag-item-context-provider/package.json +3 -0
- package/package.json +103 -4
- package/post-by-id-context-provider/package.json +3 -0
- package/post-context-provider/package.json +3 -0
- package/post-item-context-provider/package.json +3 -0
- package/related-posts-context-provider/package.json +3 -0
- package/tag-item-context-provider/package.json +3 -0
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/@wix/editor-react-types/dist/links.d.ts
|
|
4
|
+
type LinkTarget = '_self' | '_blank';
|
|
5
|
+
/**
|
|
6
|
+
* A link to a URL, used for navigation within components.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import type { Link } from '@wix/editor-react-types';
|
|
11
|
+
*
|
|
12
|
+
* interface MyComponentProps {
|
|
13
|
+
* link?: Link;
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
type Link = {
|
|
18
|
+
/**
|
|
19
|
+
* The link URL. For partial links (see `pageRole`), this is the router prefix
|
|
20
|
+
* (e.g. `https://www.my-site.com/prefix`) rather than a fully resolved URL.
|
|
21
|
+
*/
|
|
22
|
+
href?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Where this link should open.
|
|
25
|
+
* - `'_self'` — opens in the same page.
|
|
26
|
+
* - `'_blank'` — opens in a new tab.
|
|
27
|
+
*/
|
|
28
|
+
target?: LinkTarget; /** The `rel` attribute of the link. Accepts LinkRel values separated by a space. */
|
|
29
|
+
rel?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Page role identifier. Present only on partial links, where only the router prefix is
|
|
32
|
+
* known and the full URL format is owned by the Router/App. Applications can use such
|
|
33
|
+
* links in functions to resolve the complete URL at runtime (e.g. for binding links).
|
|
34
|
+
* Resolved links will not have this field.
|
|
35
|
+
*/
|
|
36
|
+
pageRole?: string;
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region ../../node_modules/@wix/editor-react-types/dist/image.d.ts
|
|
40
|
+
type Point = {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
};
|
|
44
|
+
type Crop = Point & {
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* An image from Wix Media.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* import type { Image } from '@wix/editor-react-types';
|
|
54
|
+
*
|
|
55
|
+
* interface MyComponentProps {
|
|
56
|
+
* image?: Image;
|
|
57
|
+
* }
|
|
58
|
+
*
|
|
59
|
+
* const MyComponent = ({ image }: MyComponentProps) => (
|
|
60
|
+
* <img src={image?.url} alt={image?.alt} />
|
|
61
|
+
* );
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
type Image = {
|
|
65
|
+
/** The image URI. */uri?: string; /** The image URL. */
|
|
66
|
+
url: string; /** The image file name. */
|
|
67
|
+
name?: string; /** The image height in pixels. */
|
|
68
|
+
height?: number; /** The image width in pixels. */
|
|
69
|
+
width?: number; /** Whether the image is animated (e.g. GIF). */
|
|
70
|
+
animated?: boolean; /** The crop region applied to the image. */
|
|
71
|
+
crop?: Crop; /** The image quality, as a percentage from 0 to 100. */
|
|
72
|
+
quality?: number; /** The image alt text for accessibility. */
|
|
73
|
+
alt?: string;
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region ../../node_modules/@wix/editor-react-types/dist/base.d.ts
|
|
77
|
+
/**
|
|
78
|
+
* A standard email address according to RFC 5321, section 4.1.2.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```tsx
|
|
82
|
+
* import type { Email } from '@wix/editor-react-types';
|
|
83
|
+
*
|
|
84
|
+
* interface MyComponentProps {
|
|
85
|
+
* contactEmail?: Email;
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
type Email = string;
|
|
90
|
+
/**
|
|
91
|
+
* A phone number string, accepting common phone number characters.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```tsx
|
|
95
|
+
* import type { Phone } from '@wix/editor-react-types';
|
|
96
|
+
*
|
|
97
|
+
* interface MyComponentProps {
|
|
98
|
+
* phoneNumber?: Phone;
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
type Phone = string;
|
|
103
|
+
/**
|
|
104
|
+
* Rich text content with resolved links.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```tsx
|
|
108
|
+
* import type { RichText } from '@wix/editor-react-types';
|
|
109
|
+
*
|
|
110
|
+
* interface MyComponentProps {
|
|
111
|
+
* description?: RichText;
|
|
112
|
+
* }
|
|
113
|
+
*
|
|
114
|
+
* const MyComponent = ({ description }: MyComponentProps) => (
|
|
115
|
+
* <div>
|
|
116
|
+
* {description?.html}
|
|
117
|
+
* {description?.linkList.map((link) => (
|
|
118
|
+
* <a key={link.href} href={link.href}>{link.href}</a>
|
|
119
|
+
* ))}
|
|
120
|
+
* </div>
|
|
121
|
+
* );
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
type RichText = {
|
|
125
|
+
/** The original rich text content. */text: string; /** The HTML content with all links resolved. */
|
|
126
|
+
html: string; /** All links present in the rich text content. */
|
|
127
|
+
linkList: Array<Link>;
|
|
128
|
+
};
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region ../../node_modules/@wix/editor-react-types/dist/visualMedia.d.ts
|
|
131
|
+
interface VisualMediaBase {
|
|
132
|
+
/** The URL of the media file */
|
|
133
|
+
src: string;
|
|
134
|
+
/** The slug for the media */
|
|
135
|
+
slug?: string;
|
|
136
|
+
/** Description of the media for accessibility purposes */
|
|
137
|
+
description?: string | RichText;
|
|
138
|
+
/** The title of the media */
|
|
139
|
+
title?: string | RichText;
|
|
140
|
+
/** The height of the media in pixels */
|
|
141
|
+
height?: number;
|
|
142
|
+
/** The width of the media in pixels */
|
|
143
|
+
width?: number;
|
|
144
|
+
/** An action when the item is clicked */
|
|
145
|
+
action?: {
|
|
146
|
+
/** The URL to navigate to when the media is clicked */link: Link | Phone | Email;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
type VisualMedia = (VisualMediaBase & {
|
|
150
|
+
type: 'image'; /** Additional parameters specific to images, such as focal point and alt text. */
|
|
151
|
+
parameters?: ImageParameters;
|
|
152
|
+
}) | (VisualMediaBase & {
|
|
153
|
+
type: 'video'; /** Additional parameters specific to videos, such as thumbnail, alt text, and whether the video has audio. */
|
|
154
|
+
parameters?: VideoParameters;
|
|
155
|
+
});
|
|
156
|
+
type VideoParameters = {
|
|
157
|
+
/** The URL of the video thumbnail */thumbnail?: string; /** Alternative text for the video */
|
|
158
|
+
alt?: string; /** Whether the video has audio */
|
|
159
|
+
hasAudio?: boolean;
|
|
160
|
+
};
|
|
161
|
+
type ImageParameters = {
|
|
162
|
+
/** The focal point for the image */focalPoint?: [number, number]; /** The alt text for the image */
|
|
163
|
+
alt?: string;
|
|
164
|
+
};
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/lib/category-picker.d.ts
|
|
167
|
+
/** The inline filter field name, and therefore the key on the stored value. */
|
|
168
|
+
declare const CATEGORY_PICKER_FIELD = "categoryId";
|
|
169
|
+
/** A WQL clause the filter picker stores for one inline field. */
|
|
170
|
+
type PickerClause = {
|
|
171
|
+
$eq?: string;
|
|
172
|
+
$in?: string[];
|
|
173
|
+
};
|
|
174
|
+
interface CategoryPickerFilter {
|
|
175
|
+
[CATEGORY_PICKER_FIELD]?: PickerClause;
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/lib/post-picker.d.ts
|
|
179
|
+
/** The inline filter field name, and therefore the key on the stored value. */
|
|
180
|
+
declare const POST_PICKER_FIELD = "postId";
|
|
181
|
+
interface PostPickerFilter {
|
|
182
|
+
[POST_PICKER_FIELD]?: PickerClause;
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/i18n/post-labels.types.d.ts
|
|
186
|
+
/** Text to show in place of an empty list of posts. */
|
|
187
|
+
interface EmptyStateLabels {
|
|
188
|
+
/** Heading to show in place of the empty list, in the site's language. */
|
|
189
|
+
title: string;
|
|
190
|
+
/** Sentence to show under the heading, in the site's language. */
|
|
191
|
+
description: string;
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region ../../node_modules/type-fest/source/observable-like.d.ts
|
|
195
|
+
declare global {
|
|
196
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
197
|
+
interface SymbolConstructor {
|
|
198
|
+
readonly observable: symbol;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
@remarks
|
|
203
|
+
The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
|
|
204
|
+
As well, some guidance on making an `Observable` to not include `closed` property.
|
|
205
|
+
@see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130
|
|
206
|
+
@see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85
|
|
207
|
+
@see https://github.com/benlesh/symbol-observable#making-an-object-observable
|
|
208
|
+
|
|
209
|
+
@category Observable
|
|
210
|
+
*/
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region ../../node_modules/@wix/sdk-types/build/index.d.ts
|
|
213
|
+
declare global {
|
|
214
|
+
interface ContextualClient {}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Creates concrete types from SDK descriptors when a contextual client is
|
|
218
|
+
* available.
|
|
219
|
+
*
|
|
220
|
+
* For a REST descriptor the built (bound) API is intersected with the original
|
|
221
|
+
* descriptor, matching what `contextualizeRESTModuleV2` returns at runtime — a
|
|
222
|
+
* value callable as the bound API and still usable as a descriptor. Keeping the
|
|
223
|
+
* descriptor half lets contextual modules be passed to descriptor-constrained
|
|
224
|
+
* helpers such as `elevate` from `@wix/sdk/context` (FEDINF-14092).
|
|
225
|
+
*
|
|
226
|
+
* The `& T` is scoped to REST descriptors — the only shape codegen wraps in
|
|
227
|
+
* `MaybeContext` — so `BuildDescriptors` (used by `createClient().use`) is left
|
|
228
|
+
* unchanged and stays bound-only. The fix lives here rather than in `elevate`,
|
|
229
|
+
* which is kept strict on purpose (see #941) so it still rejects bound-only
|
|
230
|
+
* functions that are unsafe through `createRESTModule`.
|
|
231
|
+
*/
|
|
232
|
+
declare global {
|
|
233
|
+
/**
|
|
234
|
+
* A global interface to set the exposure toggle for the SDK.
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* declare global {
|
|
238
|
+
* interface SDKExposureToggle {
|
|
239
|
+
* alpha: true;
|
|
240
|
+
* }
|
|
241
|
+
* }
|
|
242
|
+
*/
|
|
243
|
+
interface SDKExposureToggle {}
|
|
244
|
+
}
|
|
245
|
+
declare global {
|
|
246
|
+
/**
|
|
247
|
+
* A global interface to set the type mode for the SDK.
|
|
248
|
+
* @example
|
|
249
|
+
* ```ts
|
|
250
|
+
* declare global {
|
|
251
|
+
* interface SDKTypeMode {
|
|
252
|
+
* strict: true;
|
|
253
|
+
* }
|
|
254
|
+
* }
|
|
255
|
+
*/
|
|
256
|
+
interface SDKTypeMode {}
|
|
257
|
+
}
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/lib/parse-post-cover-media.d.ts
|
|
260
|
+
/** Playable file of a cover video uploaded to Wix. */
|
|
261
|
+
interface VideoSource {
|
|
262
|
+
/** URL of the video file. */
|
|
263
|
+
url: string;
|
|
264
|
+
/** Width of the video, in pixels. `undefined` when it isn't known. */
|
|
265
|
+
width?: number;
|
|
266
|
+
/** Height of the video, in pixels. `undefined` when it isn't known. */
|
|
267
|
+
height?: number;
|
|
268
|
+
}
|
|
269
|
+
/** Site that hosts an embedded cover video. */
|
|
270
|
+
type EmbedProvider =
|
|
271
|
+
/**
|
|
272
|
+
* YouTube. `embedUrl` is the video in YouTube's player, set to play as soon as it loads,
|
|
273
|
+
* so load it only after a site visitor clicks to play.
|
|
274
|
+
*/
|
|
275
|
+
'youtube'
|
|
276
|
+
/**
|
|
277
|
+
* Vimeo. `embedUrl` is the video in Vimeo's player, set to play as soon as it loads, so
|
|
278
|
+
* load it only after a site visitor clicks to play.
|
|
279
|
+
*/
|
|
280
|
+
| 'vimeo' /** Any other site. There's no `embedUrl`, so show the thumbnail instead of a player. */ | 'unknown';
|
|
281
|
+
/**
|
|
282
|
+
* Post's cover. It's an image, a video uploaded to Wix, or a video from another site, such as
|
|
283
|
+
* YouTube, embedded by its URL.
|
|
284
|
+
*/
|
|
285
|
+
type CoverMedia = {
|
|
286
|
+
/** Image cover. */kind: 'image'; /** Cover image, with its URL, size, and alt text. */
|
|
287
|
+
image: Image;
|
|
288
|
+
} | {
|
|
289
|
+
/** Cover video uploaded to Wix. */kind: 'wixVideo'; /** Video ID. */
|
|
290
|
+
id: string;
|
|
291
|
+
/**
|
|
292
|
+
* URL of the video's poster image, the image shown before the video plays.
|
|
293
|
+
*
|
|
294
|
+
* `undefined` when the video has no poster image.
|
|
295
|
+
*/
|
|
296
|
+
posterUrl?: string; /** Width of the poster image, in pixels. `undefined` when it isn't known. */
|
|
297
|
+
posterWidth?: number; /** Height of the poster image, in pixels. `undefined` when it isn't known. */
|
|
298
|
+
posterHeight?: number;
|
|
299
|
+
/**
|
|
300
|
+
* Playable files of the video, the recommended one first.
|
|
301
|
+
*
|
|
302
|
+
* Empty when the video's files couldn't be loaded. Show the poster image instead.
|
|
303
|
+
*/
|
|
304
|
+
sources: VideoSource[]; /** Alt text for the cover. The post's title when the cover has no alt text. */
|
|
305
|
+
altText: string;
|
|
306
|
+
} | {
|
|
307
|
+
/** Cover video embedded from another site, such as YouTube. */kind: 'embed'; /** Site that hosts the video. */
|
|
308
|
+
provider: EmbedProvider; /** URL of the video on its own site. */
|
|
309
|
+
videoUrl: string;
|
|
310
|
+
/**
|
|
311
|
+
* URL of the video in its site's player, set to play as soon as it loads.
|
|
312
|
+
*
|
|
313
|
+
* `undefined` when `provider` is `'unknown'`.
|
|
314
|
+
*/
|
|
315
|
+
embedUrl?: string;
|
|
316
|
+
/**
|
|
317
|
+
* URL of the video's thumbnail image.
|
|
318
|
+
*
|
|
319
|
+
* `undefined` when the video has no thumbnail.
|
|
320
|
+
*/
|
|
321
|
+
thumbnailUrl?: string; /** Width of the thumbnail image, in pixels. `undefined` when it isn't known. */
|
|
322
|
+
thumbnailWidth?: number; /** Height of the thumbnail image, in pixels. `undefined` when it isn't known. */
|
|
323
|
+
thumbnailHeight?: number; /** Alt text for the cover. The post's title when the cover has no alt text. */
|
|
324
|
+
altText: string;
|
|
325
|
+
};
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/extensions/post-list-context-provider/utils.d.ts
|
|
328
|
+
/** Post with its fields ready to show in a repeater item. */
|
|
329
|
+
interface PostListItem {
|
|
330
|
+
/** Post ID. */
|
|
331
|
+
_id: string;
|
|
332
|
+
/** Post's title, as plain text. */
|
|
333
|
+
title: string;
|
|
334
|
+
/**
|
|
335
|
+
* Post's title, as rich text. Its `text` field holds the plain text, and its `html` field
|
|
336
|
+
* holds the text as an HTML paragraph.
|
|
337
|
+
*/
|
|
338
|
+
itemTitle: RichText;
|
|
339
|
+
/** Post's excerpt, as rich text. Empty when the post has no excerpt. */
|
|
340
|
+
itemExcerpt: RichText;
|
|
341
|
+
/**
|
|
342
|
+
* Post's cover image, with its URL, size, and alt text. For a post whose cover is a video
|
|
343
|
+
* uploaded to Wix, the video's poster image.
|
|
344
|
+
*
|
|
345
|
+
* `undefined` when there's no image to show, such as when the cover is an embedded video.
|
|
346
|
+
*
|
|
347
|
+
* It holds the cover image even when the post's author hid the cover. To leave out a hidden
|
|
348
|
+
* cover, check `itemCoverMedia`, which is `undefined` then.
|
|
349
|
+
*/
|
|
350
|
+
itemCoverImage: Image | undefined;
|
|
351
|
+
/**
|
|
352
|
+
* Post's cover as an image or a playable video. Use it to play a video cover, which
|
|
353
|
+
* `itemCoverImage` holds only as its poster image.
|
|
354
|
+
*
|
|
355
|
+
* `undefined` when the post has no cover, or the post's author hid it.
|
|
356
|
+
*/
|
|
357
|
+
itemCoverMedia: CoverMedia | undefined;
|
|
358
|
+
/**
|
|
359
|
+
* Link to the post's page. `href` is the page's URL, and `target` is `'_self'`, so the link
|
|
360
|
+
* opens in the same tab.
|
|
361
|
+
*
|
|
362
|
+
* `undefined` when the post has no slug and no URL.
|
|
363
|
+
*/
|
|
364
|
+
itemLink: Link | undefined;
|
|
365
|
+
/**
|
|
366
|
+
* Date the post was first published, as rich text in the site's regional format. In the
|
|
367
|
+
* week after publishing, it's relative, such as "3 days ago". After that, it's a date, such
|
|
368
|
+
* as "Aug 5", with the year when it isn't the current year.
|
|
369
|
+
*/
|
|
370
|
+
itemPublishedDate: RichText;
|
|
371
|
+
/**
|
|
372
|
+
* Date the post was first published, as an
|
|
373
|
+
* [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) string.
|
|
374
|
+
*
|
|
375
|
+
* `undefined` when the post has no publish date.
|
|
376
|
+
*/
|
|
377
|
+
publishedDateValue: string | undefined;
|
|
378
|
+
/**
|
|
379
|
+
* Current time that `itemPublishedDate` is relative to, in milliseconds since the Unix
|
|
380
|
+
* epoch.
|
|
381
|
+
*
|
|
382
|
+
* When you format `publishedDateValue` as a relative date yourself, use this value as the
|
|
383
|
+
* current time, so your text matches `itemPublishedDate`.
|
|
384
|
+
*/
|
|
385
|
+
clockValue: number;
|
|
386
|
+
/**
|
|
387
|
+
* Estimated reading time, in minutes.
|
|
388
|
+
*
|
|
389
|
+
* `undefined` when the post has no estimate.
|
|
390
|
+
*/
|
|
391
|
+
minutesToReadValue: number | undefined;
|
|
392
|
+
/**
|
|
393
|
+
* Number of times the post was viewed, as loaded with the post.
|
|
394
|
+
*
|
|
395
|
+
* `undefined` when the count wasn't loaded with the post. In the editor, but not in Preview,
|
|
396
|
+
* a sample number instead.
|
|
397
|
+
*/
|
|
398
|
+
initialViewCount: number | undefined;
|
|
399
|
+
/**
|
|
400
|
+
* Number of comments on the post, as loaded with the post.
|
|
401
|
+
*
|
|
402
|
+
* `undefined` when the count wasn't loaded with the post. In the editor, but not in Preview,
|
|
403
|
+
* a sample number instead.
|
|
404
|
+
*/
|
|
405
|
+
initialCommentCount: number | undefined;
|
|
406
|
+
/** Name of the post's author, as rich text. Empty when the author isn't found. */
|
|
407
|
+
authorName: RichText;
|
|
408
|
+
/**
|
|
409
|
+
* Author's profile photo, with its URL, size, and alt text. The alt text is the author's
|
|
410
|
+
* name, or a generic author-photo label when the author has no name.
|
|
411
|
+
*
|
|
412
|
+
* `undefined` when the author has no photo.
|
|
413
|
+
*/
|
|
414
|
+
authorImage: Image | undefined;
|
|
415
|
+
/**
|
|
416
|
+
* Estimated reading time as rich text in the site's language, such as "5 min read".
|
|
417
|
+
*
|
|
418
|
+
* Empty when the post has no estimate.
|
|
419
|
+
*/
|
|
420
|
+
timeToRead: RichText;
|
|
421
|
+
/**
|
|
422
|
+
* Number of views as rich text in the site's language, such as "1,234 views".
|
|
423
|
+
*
|
|
424
|
+
* Empty when the count wasn't loaded with the post. In the editor, but not in Preview, a
|
|
425
|
+
* sample count instead.
|
|
426
|
+
*/
|
|
427
|
+
viewCount: RichText;
|
|
428
|
+
/**
|
|
429
|
+
* Number of comments as rich text in the site's language.
|
|
430
|
+
*
|
|
431
|
+
* Empty when the count wasn't loaded with the post. In the editor, but not in Preview, a
|
|
432
|
+
* sample count instead.
|
|
433
|
+
*/
|
|
434
|
+
commentCount: RichText;
|
|
435
|
+
/**
|
|
436
|
+
* Name of the post's main category, as rich text. It's the first of the post's categories
|
|
437
|
+
* that still exists.
|
|
438
|
+
*
|
|
439
|
+
* Empty when none of the post's categories exists. In the editor, but not in Preview, a
|
|
440
|
+
* sample name instead.
|
|
441
|
+
*/
|
|
442
|
+
itemCategoryLabel: RichText;
|
|
443
|
+
/** Post's title and slug, as plain text. */
|
|
444
|
+
recentPostItem: {
|
|
445
|
+
/** Post's title. */title: string; /** Post's slug, the last part of the post page's URL. */
|
|
446
|
+
slug: string;
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* Whether site visitors can comment on the post.
|
|
450
|
+
*
|
|
451
|
+
* `undefined` when it isn't known, such as for the sample posts in the editor.
|
|
452
|
+
*/
|
|
453
|
+
commentingEnabled: boolean | undefined;
|
|
454
|
+
}
|
|
455
|
+
/** Text to show in place of an empty list of posts. */
|
|
456
|
+
type EmptyStateContent = EmptyStateLabels;
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region src/extensions/post-list-context-provider/post-list-context-provider.d.ts
|
|
459
|
+
/** View of the feed that the page's URL shows. It's all posts, one category, or one tag. */
|
|
460
|
+
type FilteredFeedView = {
|
|
461
|
+
/**
|
|
462
|
+
* Loading state, while the first page of posts loads.
|
|
463
|
+
*
|
|
464
|
+
* Also `'pending'` when the posts failed to show, with `hasError` set to `true`.
|
|
465
|
+
*/
|
|
466
|
+
kind: 'pending';
|
|
467
|
+
} | {
|
|
468
|
+
/**
|
|
469
|
+
* Unfiltered feed. The URL isn't a category or tag page.
|
|
470
|
+
*
|
|
471
|
+
* Also `'all'` when no category or tag matches the URL, and the feed is then empty, and
|
|
472
|
+
* when the first page of posts failed to load.
|
|
473
|
+
*/
|
|
474
|
+
kind: 'all';
|
|
475
|
+
} | {
|
|
476
|
+
/** Category's posts, on a category page such as `/blog/category/<slug>`. */kind: 'category'; /** Category's name. */
|
|
477
|
+
title: string; /** Category's description. Empty when the category has none. */
|
|
478
|
+
description: string;
|
|
479
|
+
/**
|
|
480
|
+
* Category's cover image, with its URL, size, and alt text.
|
|
481
|
+
*
|
|
482
|
+
* `undefined` when the category has no cover image.
|
|
483
|
+
*/
|
|
484
|
+
coverImage: Image | undefined;
|
|
485
|
+
} | {
|
|
486
|
+
/** Tag's posts, on a tag page such as `/blog/tag/<slug>`. */kind: 'tag'; /** Tag's name. */
|
|
487
|
+
title: string;
|
|
488
|
+
};
|
|
489
|
+
/** The blog feed: its posts, loading and error state, and paging, as read through {@link useBlogFeedContext}. */
|
|
490
|
+
interface PostListContextType {
|
|
491
|
+
/**
|
|
492
|
+
* Posts in the feed, one item per post, in the order the feed shows them.
|
|
493
|
+
*
|
|
494
|
+
* The list starts with the first page of posts, and `loadMorePosts()` adds each later page
|
|
495
|
+
* to its end. It's empty while the first page loads, and when the first page failed to
|
|
496
|
+
* load.
|
|
497
|
+
*
|
|
498
|
+
* In the editor, but not in Preview, the list holds three sample posts to design with when
|
|
499
|
+
* the feed has no posts, the page isn't a category or tag page, and none of the
|
|
500
|
+
* **Category**, **Posts**, and **Featured Posts Only** settings is set. Preview and the live
|
|
501
|
+
* site show the empty list.
|
|
502
|
+
*/
|
|
503
|
+
postsList: PostListItem[];
|
|
504
|
+
/**
|
|
505
|
+
* Posts in the feed as gallery media items, in the same order as `postsList`. Each item
|
|
506
|
+
* holds the post's cover image or video, the post's title and excerpt, and a link to the
|
|
507
|
+
* post's page.
|
|
508
|
+
*
|
|
509
|
+
* Posts with no cover, or whose author hid the cover, are left out. A post whose cover is an
|
|
510
|
+
* embedded video, such as a YouTube video, appears as the video's thumbnail image, and is
|
|
511
|
+
* left out when the video has no thumbnail.
|
|
512
|
+
*
|
|
513
|
+
* In the editor, but not in Preview, the list holds three sample items to design with when
|
|
514
|
+
* no post in the feed has a cover, the page isn't a category or tag page, and none of the
|
|
515
|
+
* **Category**, **Posts**, and **Featured Posts Only** settings is set.
|
|
516
|
+
*/
|
|
517
|
+
postGalleryItems: VisualMedia[];
|
|
518
|
+
/**
|
|
519
|
+
* Title and description to show in place of the posts when the feed has no posts, in the
|
|
520
|
+
* site's language.
|
|
521
|
+
*
|
|
522
|
+
* `null` while the feed has posts, while the first page of posts loads, and when posts
|
|
523
|
+
* failed to load. In the editor, it's set for an empty feed even while `postsList` holds
|
|
524
|
+
* sample posts, so check that `postsList` is empty before you show it.
|
|
525
|
+
*/
|
|
526
|
+
emptyState: EmptyStateContent | null;
|
|
527
|
+
/**
|
|
528
|
+
* Whether posts failed to load.
|
|
529
|
+
*
|
|
530
|
+
* While it's `true`, `emptyState` is `null`, so show an error message instead of a message
|
|
531
|
+
* that the blog has no posts.
|
|
532
|
+
*
|
|
533
|
+
* A failed `loadMorePosts()` call sets it to `true` and keeps the posts already loaded. The
|
|
534
|
+
* next successful `loadMorePosts()` call sets it back to `false`.
|
|
535
|
+
*
|
|
536
|
+
* When the first page of posts failed to load, `hasMorePosts` is `false`, so
|
|
537
|
+
* `loadMorePosts()` does nothing and `hasError` stays `true`. Reloading the page tries
|
|
538
|
+
* again.
|
|
539
|
+
*/
|
|
540
|
+
hasError: boolean;
|
|
541
|
+
/**
|
|
542
|
+
* Whether `loadMorePosts()` can load more posts.
|
|
543
|
+
*
|
|
544
|
+
* `false` when the feed shows hand-picked posts, because they all load at once. When the
|
|
545
|
+
* number of posts is an exact multiple of the number loaded at a time, it stays `true`
|
|
546
|
+
* until a `loadMorePosts()` call finds no more posts.
|
|
547
|
+
*
|
|
548
|
+
* Also `false` while the first page of posts loads, and when it failed to load.
|
|
549
|
+
*/
|
|
550
|
+
hasMorePosts: boolean;
|
|
551
|
+
/**
|
|
552
|
+
* Whether posts are loading. `true` while the first page of posts loads, and while
|
|
553
|
+
* `loadMorePosts()` loads another page.
|
|
554
|
+
*/
|
|
555
|
+
isLoadingPosts: boolean;
|
|
556
|
+
/**
|
|
557
|
+
* Loads the next page of posts and adds it to the end of `postsList` and `postGalleryItems`.
|
|
558
|
+
*
|
|
559
|
+
* A page holds the number of posts set in the **Posts** Data Source's **Posts Per Load**
|
|
560
|
+
* setting, up to 100, or 6 when it isn't set.
|
|
561
|
+
*
|
|
562
|
+
* Does nothing when `hasMorePosts` is `false`. A call made while a page is loading returns
|
|
563
|
+
* the promise of the call in progress, so each page loads once.
|
|
564
|
+
*
|
|
565
|
+
* When the page fails to load, the promise still resolves. `hasError` becomes `true`, and
|
|
566
|
+
* the next call tries the same page again.
|
|
567
|
+
*
|
|
568
|
+
* @returns Promise that resolves when the page has loaded, or has failed to load.
|
|
569
|
+
*
|
|
570
|
+
* @example Add a button that loads more posts
|
|
571
|
+
* ```tsx
|
|
572
|
+
* import { useBlogFeedContext } from '@wix/blog/blog-feed-context-provider';
|
|
573
|
+
*
|
|
574
|
+
* function LoadMoreButton() {
|
|
575
|
+
* const { hasMorePosts, isLoadingPosts, loadMorePosts } = useBlogFeedContext();
|
|
576
|
+
*
|
|
577
|
+
* if (!hasMorePosts) {
|
|
578
|
+
* return null;
|
|
579
|
+
* }
|
|
580
|
+
*
|
|
581
|
+
* return (
|
|
582
|
+
* <button disabled={isLoadingPosts} onClick={() => loadMorePosts()}>
|
|
583
|
+
* {isLoadingPosts ? 'Loading...' : 'Load more posts'}
|
|
584
|
+
* </button>
|
|
585
|
+
* );
|
|
586
|
+
* }
|
|
587
|
+
* ```
|
|
588
|
+
*/
|
|
589
|
+
loadMorePosts: () => Promise<void>;
|
|
590
|
+
/**
|
|
591
|
+
* View of the feed that the page's URL shows, with the category's or tag's details. It's
|
|
592
|
+
* all posts, one category, or one tag.
|
|
593
|
+
*
|
|
594
|
+
* It's set from the URL when the first page of posts loads, and doesn't change when
|
|
595
|
+
* `loadMorePosts()` loads more posts.
|
|
596
|
+
*
|
|
597
|
+
* @example Show the category's or tag's name above the posts
|
|
598
|
+
* ```tsx
|
|
599
|
+
* import { useBlogFeedContext } from '@wix/blog/blog-feed-context-provider';
|
|
600
|
+
*
|
|
601
|
+
* function FeedHeading() {
|
|
602
|
+
* const { filteredView } = useBlogFeedContext();
|
|
603
|
+
*
|
|
604
|
+
* switch (filteredView.kind) {
|
|
605
|
+
* case 'category':
|
|
606
|
+
* return (
|
|
607
|
+
* <header>
|
|
608
|
+
* <h1>{filteredView.title}</h1>
|
|
609
|
+
* <p>{filteredView.description}</p>
|
|
610
|
+
* </header>
|
|
611
|
+
* );
|
|
612
|
+
* case 'tag':
|
|
613
|
+
* return <h1>Posts tagged {filteredView.title}</h1>;
|
|
614
|
+
* case 'all':
|
|
615
|
+
* return <h1>All posts</h1>;
|
|
616
|
+
* default:
|
|
617
|
+
* return null;
|
|
618
|
+
* }
|
|
619
|
+
* }
|
|
620
|
+
* ```
|
|
621
|
+
*/
|
|
622
|
+
filteredView: FilteredFeedView;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* The Blog Feed context provides access to a list of the site's published blog posts, loaded
|
|
626
|
+
* a page at a time. Use it to show posts, load more of them, and show the feed's empty,
|
|
627
|
+
* loading, and error states.
|
|
628
|
+
*/
|
|
629
|
+
declare function useBlogFeedContext(): PostListContextType;
|
|
630
|
+
/** Loads a page of blog posts, filtered by the URL view or the picked category or posts, and supplies them as a feed. */
|
|
631
|
+
declare function PostListProvider({
|
|
632
|
+
children,
|
|
633
|
+
categoryPicker,
|
|
634
|
+
postsPicker,
|
|
635
|
+
pageSize,
|
|
636
|
+
postOffset,
|
|
637
|
+
sortOrder,
|
|
638
|
+
featuredOnly,
|
|
639
|
+
liveRefreshGeneration
|
|
640
|
+
}: {
|
|
641
|
+
children?: React.ReactNode;
|
|
642
|
+
/**
|
|
643
|
+
* The manifest's `data.categoryPicker` filter — `{ categoryId: { $eq: '<id>' } }` as the
|
|
644
|
+
* editor's Items Selection picker stores it; absent/empty means unfiltered.
|
|
645
|
+
*/
|
|
646
|
+
categoryPicker?: CategoryPickerFilter;
|
|
647
|
+
/**
|
|
648
|
+
* The manifest's `data.postsPicker` filter — `{ postId: { $in: ['<id>', ...] } }`; absent/empty
|
|
649
|
+
* means no hand-picked posts.
|
|
650
|
+
*/
|
|
651
|
+
postsPicker?: PostPickerFilter; /** The manifest's `data.pageSize` input — unset/invalid falls back to 6. */
|
|
652
|
+
pageSize?: number; /** The manifest's `data.postOffset` input — unset/invalid falls back to 0 (no skip). */
|
|
653
|
+
postOffset?: number; /** The manifest's `data.sortOrder` select — unset/unknown falls back to 'newest'. */
|
|
654
|
+
sortOrder?: string; /** The manifest's `data.featuredOnly` toggle — unset means all posts. */
|
|
655
|
+
featuredOnly?: boolean;
|
|
656
|
+
/**
|
|
657
|
+
* Not a manifest input: the editor entry bumps it when the dashboard changes a post
|
|
658
|
+
* (`post-list-context-provider.editor.tsx`). Above 0 the first page skips the warmup
|
|
659
|
+
* slot (`key: null`), because a live refetch must never be answered from it.
|
|
660
|
+
*/
|
|
661
|
+
liveRefreshGeneration?: number;
|
|
662
|
+
}): React.ReactNode;
|
|
663
|
+
|
|
664
|
+
export { type EmptyStateContent, type FilteredFeedView, type PostListContextType, type PostListItem, PostListProvider, PostListProvider as default, useBlogFeedContext };
|