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: README.md
+94-25Lines changed: 94 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,38 +25,49 @@ npm i @contentstack/utils
25
25
Let’s learn how you can use Utils SDK to render embedded items.
26
26
27
27
### Create Render Option
28
-
To render embedded items on the front-end, use the renderOptions function, and define the UI elements you want to show in the front-end of your website, as shown in the example below:
28
+
To render embedded items on the front-end, use the renderOptions function, and define the UI elements you want to show in the front-end of your website, as shown in the example below:
29
29
```js
30
30
constrenderOptions= {
31
-
//to render block-type embedded items
31
+
// to render Supercharged RTE NodeType content like paragraph, link, table, order list, un-order list and more.
32
+
p: (node, next) => {
33
+
`<p class='class-id'>${next(node.children)}</p>`// you will need to call next function with node children contents
34
+
}
35
+
h1: (node, next) => {
36
+
`<h1 class='class-id'>${next(node.children)}</h1>`// you will need to call next function with node children contents
37
+
}
38
+
// to render Supercharged RTE MarkType content like bold, italic, underline, strickthrough, inlineCode, subscript, and superscript
Contentstack Utils SDK lets you interact with the Content Delivery APIs and retrieve embedded items from the RTE field of an entry.
67
78
68
79
### Fetch Embedded Item(s) from a Single Entry
69
-
To get an embedded item of a single entry, you need to provide the stack API key, environment name, delivery token, content type and entry UID. Then, use the includeEmbeddedItems and Contentstack.Utils.render functions as shown below:
80
+
#### Render HTML RTE Embedded object
81
+
To get an embedded item of a single entry, you need to provide the stack API key, environment name, delivery token, content type and entry UID. Then, use the `includeEmbeddedItems` and `Contentstack.Utils.render` functions as shown below:
70
82
```js
71
83
import*asContentstackfrom'contentstack'
72
84
conststack=Contentstack.Stack({
@@ -88,9 +100,35 @@ If you have multiple RTE fields in an entry and want to fetch the embedded items
88
100
Refer to the example code below:
89
101
```js
90
102
//code to render embedded item from an RTE field and from another RTE field nested within a group field
To get a single entry, you need to provide the stack API key, environment name, delivery token, content type and entry UID. Then, use `Contentstack.Utils.jsonToHtml` function as shown below:
> Node: Supercharged RTE also supports Embedded items to get all embedded items while fetching entry use `includeEmbeddedItems` function.
128
+
93
129
### Fetch Embedded Item(s) from Multiple Entries
130
+
#### Render HTML RTE Embedded object
131
+
94
132
To get embedded items from multiple entries, you need to provide the content type UID. You can also use the path variable in case the entries have multiple RTE fields.
To get a multiple entries, you need to provide the stack API key, environment name, delivery token, content type and entry UID. Then, use `Contentstack.Utils.jsonToHtml` function as shown below:
0 commit comments