Skip to content

Commit 2e9a140

Browse files
committed
adding a few more content blocks
1 parent e628cb8 commit 2e9a140

1 file changed

Lines changed: 108 additions & 0 deletions

File tree

src/content/docs/react/guides/content-blocks.mdx

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,114 @@ const conditionalRoute = {
202202
plugins.content.render(conditionalRoute)
203203
```
204204

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+
<Aside type="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+
205313
## Layouts
206314

207315
Each content block can have different layouts that change how it's presented.

0 commit comments

Comments
 (0)