Skip to content

Commit 9771856

Browse files
authored
Feature: Update README.md with Default Chunks and Variables (#21)
* Update README.md * add semicolon
1 parent 4be10a4 commit 9771856

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,44 @@ function Example() {
8484

8585
This will render editable headings containing the name and title and an image containing the headshot for every person in the "Team Member" collection.
8686

87+
#### Using default chunks array as fallback:
88+
89+
For cases when there's no internet connection but your app is designed to work in offline mode, Editmode supports having an array of default chunks as fallback.
90+
91+
```js
92+
const defaultChunksValue = [
93+
{"identifier":"cnk_2177d77492a2dead1585","chunk_type":"single_line_text","project_id":"prj_h3Gk3gFVMXbl","branch_id":"d1dWhVyF85Yr","master_branch":true,"content_key":"","content":"This is a single line text!"},
94+
];
95+
96+
function Example() {
97+
return (
98+
<section>
99+
<Editmode projectId="prj_h3Gk3gFVMXbl" defaultChunks={defaultChunksValue}>
100+
<Chunk identifier="cnk_2177d77492a2dead1585" />
101+
</Editmode>
102+
</section>
103+
);
104+
}
105+
```
106+
107+
#### Using variables:
108+
109+
Variables that are created in the Editmode CMS are also supported by passing an object prop as `variables`.
110+
111+
```js
112+
function Example() {
113+
return (
114+
<section>
115+
<Editmode projectId="prj_h3Gk3gFVMXbl" defaultChunks={defaultChunksValue}>
116+
<Chunk identifier="cnk_2177d77492a2dead1585" variables={{ "name": "John" }} />
117+
</Editmode>
118+
</section>
119+
);
120+
}
121+
```
122+
123+
With this, chunks such as `Hello, {{name}}!` will be parsed as `Hello, John!`
124+
87125
### Step 3:
88126

89127
You can now edit and save all of the chunks in your React app from within the browser - just add `editmode=1` as a query string parameter to the current URL.

0 commit comments

Comments
 (0)