You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/react/guides/content-blocks.mdx
+108Lines changed: 108 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -202,6 +202,114 @@ const conditionalRoute = {
202
202
plugins.content.render(conditionalRoute)
203
203
```
204
204
205
+
### API Content
206
+
207
+
API Content fetches and displays data from external APIs.
208
+
209
+
```tsx
210
+
// API Content object
211
+
const apiContent = {
212
+
_type: 'vyuh.apiContent',
213
+
showPending: true, // Show visual feedback during loading
214
+
showError: true, // Show visual feedback for errors
215
+
configuration: [
216
+
{
217
+
_type: 'your-api-configuration-type', // Custom API configuration type
218
+
// Configuration properties specific to your API implementation
219
+
}
220
+
]
221
+
}
222
+
223
+
// Render with content plugin
224
+
plugins.content.render(apiContent)
225
+
```
226
+
227
+
<Asidetype="note">
228
+
API Content requires a custom API configuration implementation that extends the `APIConfiguration` class. This allows you to define how to fetch data and render the results.
229
+
</Aside>
230
+
231
+
### Divider
232
+
233
+
Dividers create visual separation between content sections.
234
+
235
+
```tsx
236
+
// Divider content object
237
+
const dividerContent = {
238
+
_type: 'vyuh.divider',
239
+
thickness: 1, // Thickness in pixels
240
+
indent: 16// Indent from edges in pixels or CSS units
241
+
}
242
+
243
+
// Render with content plugin
244
+
plugins.content.render(dividerContent)
245
+
```
246
+
247
+
### Document
248
+
249
+
Document content blocks represent structured documents with content items.
250
+
251
+
```tsx
252
+
// Document content object
253
+
const documentContent = {
254
+
_type: 'vyuh.document',
255
+
title: 'Documentation',
256
+
description: 'A comprehensive guide',
257
+
items: [
258
+
// Array of content items that make up the document
259
+
{
260
+
_type: 'vyuh.portableText',
261
+
blocks: [/* Portable text content */]
262
+
},
263
+
{
264
+
_type: 'vyuh.card',
265
+
title: 'Example Card'
266
+
}
267
+
]
268
+
}
269
+
270
+
// Render with content plugin
271
+
plugins.content.render(documentContent)
272
+
```
273
+
274
+
### Document View
275
+
276
+
Document View loads and displays a document by reference or query.
277
+
278
+
```tsx
279
+
// Document View content object
280
+
const documentViewContent = {
281
+
_type: 'vyuh.document.view',
282
+
title: 'Product Documentation',
283
+
loadStrategy: 'reference', // 'reference' or 'query'
284
+
reference: { _ref: 'document-123' }, // Used when loadStrategy is 'reference'
285
+
// query: { ... } // Used when loadStrategy is 'query'
286
+
}
287
+
288
+
// Render with content plugin
289
+
plugins.content.render(documentViewContent)
290
+
```
291
+
292
+
### Video Player
293
+
294
+
Video Player renders video content with playback controls.
295
+
296
+
```tsx
297
+
// Video Player content object
298
+
const videoPlayerContent = {
299
+
_type: 'vyuh.videoPlayer',
300
+
title: 'Product Demo',
301
+
linkType: 'url', // 'url' or 'file'
302
+
url: 'https://example.com/videos/demo.mp4', // Used when linkType is 'url'
303
+
// file: { _ref: 'file-123' }, // Used when linkType is 'file'
304
+
loop: false,
305
+
autoplay: false,
306
+
muted: false
307
+
}
308
+
309
+
// Render with content plugin
310
+
plugins.content.render(videoPlayerContent)
311
+
```
312
+
205
313
## Layouts
206
314
207
315
Each content block can have different layouts that change how it's presented.
0 commit comments