Skip to content

Commit 16b73fe

Browse files
martin3walkerjescalan
authored andcommitted
Add section on includeLevel to readme
Include a section about how to return links more than one level deep. Useful because the content structure advocated for by Contentful makes heavy use of references. So, this seems like a problem many people could run into.
1 parent 463cd85 commit 16b73fe

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,31 @@ new Contentful({
117117
})
118118
```
119119

120+
### Returning Linked Content Entries
121+
122+
Contentful allows you to link content types with a field called references. This can create a chain of links. For example __Content Entry A__ could contain a reference to __Content Entry B__, and __Content Entry B__ could further reference __Content Entry C__.
123+
124+
Spike's default settings return only the first level of links, meaning that returning __Content Entry A__ from above will also retun __Content Entry B__, but not __Content Entry C__. There is an option called includeLevel that can be included in your Contentful object, which will allow you to return more levels of links than the default 1. This is extremely helpful if your content model relies heavily on references.
125+
126+
```js
127+
new Contentful({
128+
addDataTo: locals,
129+
accessToken: 'xxx',
130+
spaceId: 'xxx',
131+
includeLevel: 10,
132+
contentTypes: [
133+
{
134+
name: 'posts',
135+
id: '633fTeiMaxxxxxxxxx',
136+
filters: {
137+
limit: 10,
138+
order: 'sys.createdAt'
139+
}
140+
}
141+
]
142+
})
143+
```
144+
120145
### Transforms
121146

122147
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.

0 commit comments

Comments
 (0)