Skip to content

Commit 9b19b29

Browse files
committed
remove default transform from readme
1 parent 3fb788d commit 9b19b29

1 file changed

Lines changed: 27 additions & 44 deletions

File tree

README.md

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,16 @@ In order to pass the data correctly, you must pass `spike-contentful` an object,
5555

5656
Once included, it will expose a `contentful` local to your markup (`.sgr`, `.html`, etc...) files, which you can use to iterate through your content types. Based on the example above, the `posts` content type will be accessible through `contentful.posts`, as such:
5757

58-
5958
```jade
6059
// a template file
6160
ul
6261
each(loop='post of contentful.posts')
6362
li {{ JSON.stringify(post) }}
6463
```
64+
6565
For the sugar-free
66-
``` html
66+
67+
```html
6768
<ul>
6869
<each loop="post of contentful.blog">
6970
<li>{{ JSON.stringify(post) }}</li>
@@ -118,7 +119,7 @@ new Contentful({
118119

119120
### Transforms
120121

121-
Contentful returns a lot of associated data and, as a result, we include a way to clean it up. You also have the ability to pass your own custom `transform` option to each content type allowing you to transform the data however you like before it's sent to your views.
122+
Contentful returns a lot of associated data and, as a result, we give you the ability to pass your own custom `transform` option to each content type allowing you to transform the data however you like before it's sent to your views.
122123

123124
```js
124125
new Contentful({
@@ -129,7 +130,7 @@ new Contentful({
129130
{
130131
name: 'posts',
131132
id: '633fTeiMaxxxxxxxxx',
132-
transform: (post) => {
133+
transform: post => {
133134
// do your transformation here...
134135
return post
135136
}
@@ -138,30 +139,6 @@ new Contentful({
138139
})
139140
```
140141

141-
This plugin ships with a default transform function that will run some basic cleanup. However, be warned that the transform will enter an infinite loop and crash if there are circular references within the data, which is not an uncommon occurance, so please be very careful utilizing this transform. To enable our default transform, you can pass `true` as such:
142-
143-
```js
144-
new Contentful({
145-
addDataTo: locals,
146-
accessToken: 'xxx',
147-
spaceId: 'xxx',
148-
contentTypes: [
149-
{
150-
name: 'posts',
151-
id: '633fTeiMaxxxxxxxxx',
152-
transform: true
153-
}
154-
]
155-
})
156-
```
157-
158-
If you'd like to use our default transform outside of the library, this is also available as an export. For example, you could include it and use it with client-side JS responses.
159-
160-
```js
161-
const Contentful = require('spike-contentful')
162-
console.log(Contentful.transform)
163-
```
164-
165142
### Templates
166143

167144
Using the template option allows you to write objects returned from Contentful to single page templates. For example, if you are trying to render a blog as static, you might want each post returned from the API to be rendered as a single page by itself.
@@ -173,14 +150,18 @@ new Contentful({
173150
addDataTo: locals,
174151
accessToken: 'xxx',
175152
spaceId: 'xxx',
176-
contentTypes: [{
177-
name: 'posts',
178-
id: '633fTeiMaxxxxxxxxx',
179-
template: {
180-
path: 'templates/post.html',
181-
output: (post) => { return `posts/${post.id}.html` }
153+
contentTypes: [
154+
{
155+
name: 'posts',
156+
id: '633fTeiMaxxxxxxxxx',
157+
template: {
158+
path: 'templates/post.html',
159+
output: post => {
160+
return `posts/${post.id}.html`
161+
}
162+
}
182163
}
183-
}]
164+
]
184165
})
185166
```
186167

@@ -199,10 +180,12 @@ new Contentful({
199180
addDataTo: locals,
200181
accessToken: 'xxx',
201182
spaceId: 'xxx',
202-
contentTypes: [{
203-
name: 'posts',
204-
id: '633fTeiMaxxxxxxxxx'
205-
}],
183+
contentTypes: [
184+
{
185+
name: 'posts',
186+
id: '633fTeiMaxxxxxxxxx'
187+
}
188+
],
206189
json: 'data.json'
207190
})
208191
```
@@ -240,11 +223,11 @@ By default, this plugin will only fetch data once when you start your watcher, f
240223

241224
To run the tests locally, you'll need to add a `test/.env` with your name and token values:
242225

243-
- `cp test/.env.sample test/.env`
244-
- `accessToken` is derived from "APIs" > "Content Delivery API Keys" in the Contentful admin section.
245-
- `spaceId` is also derived from "APIs" > "Content Delivery API Keys" in the Contentful admin section.
226+
* `cp test/.env.sample test/.env`
227+
* `accessToken` is derived from "APIs" > "Content Delivery API Keys" in the Contentful admin section.
228+
* `spaceId` is also derived from "APIs" > "Content Delivery API Keys" in the Contentful admin section.
246229

247230
### License & Contributing
248231

249-
- Details on the license [can be found here](LICENSE.md)
250-
- Details on running tests and contributing [can be found here](CONTRIBUTING.md)
232+
* Details on the license [can be found here](LICENSE.md)
233+
* Details on running tests and contributing [can be found here](CONTRIBUTING.md)

0 commit comments

Comments
 (0)