-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathportabletext-mapped-type-property.astro
50 lines (47 loc) · 1.13 KB
/
portabletext-mapped-type-property.astro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
/**
* This example demonstrates how to map custom components to different
* Portable Text node type properties.
*
* It shows how to use the `components` prop to customize rendering for:
* - Custom types (`_type`)
* - Block styles (`style`)
* - List types (`listItem`)
* - Mark types (`markType`)
*/
// @ts-nocheck
import { PortableText } from "astro-portabletext";
import Hero from "./Hero.astro";
import Map from "./Map.astro";
import PageHeading from "./PageHeading.astro";
import BulletListWrapper from "./BulletListWrapper.astro";
import BulletListItem from "./BulletListItem.astro";
import Highlight from "./Highlight.astro";
const portableText = [
/* Portable Text payload */
];
const components = {
type: {
hero: Hero,
map: Map,
// [node._type]: Component
},
block: {
h1: PageHeading,
// [node.style]: Component
},
list: {
bullet: BulletListWrapper,
// [node.listItem]: Component
},
listItem: {
bullet: BulletListItem,
// [node.listItem]: Component
},
mark: {
highlight: Highlight,
// [node.markType]: Component
},
};
---
<PortableText value={portableText} {components} />