Skip to content

Commit

Permalink
Add the contentType in child entries
Browse files Browse the repository at this point in the history
  • Loading branch information
drublic committed Mar 10, 2017
1 parent 1aae6e6 commit b9ca69d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Contentful.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,16 @@ class Contentful {
*/
_cleanEntry (entry, full = false) {
let newEntry = {};
let contentType;

if (entry.sys) {
contentType = entry.sys.contentType.sys.id;

if (full) {
delete entry.sys;
} else {
delete entry.sys.space;
delete entry.sys.contentType;
delete entry.sys.type;
delete entry.sys.revision;

Expand All @@ -105,6 +109,11 @@ class Contentful {
}

newEntry.fields = entry.fields;
newEntry.fields.contentType = {};

this.locales.forEach((locale) => {
newEntry.fields.contentType[locale[0]] = contentType;
});

return newEntry;
}
Expand Down

0 comments on commit b9ca69d

Please sign in to comment.