Resentful
A tiny little utility to make Contentful API responses easier to manage
Example
Turn this:
Into this:
Usage
Pretty darn simple:
const Resentful = ;const resentful = ;const reduced = resentful;
Mappers
Need to hang onto some metadata in some cases? Just grab it during a pre-mapping phase for the contentType
and dump it into the fields
object, and it'll be treated just like a normal property:
const Resentful = ;const resentful = ; resentful; const reduced = resentful; // Produces// {// ...,// "nestedConfig": {// ...,// "meta": {// "contentType": "nestedConfig"// } // }// }
Need to do some post-processing on a reduced entry? Just grab it during a post-mapping phase for the contentType
and modify it:
const Resentful = ;const resentful = ; resentful; const reduced = resentful; // Produces// {// ...,// "nestedConfig": {// ...,// "nestedNumberField": 64321// }// }
Api
-
Resentful() Constructor, no available arguments
-
registerMappers(contentType, preMapper, postMapper) Registers optional pre- and post-mappers for the given
contentType
, as indicated byentry.sys.contentType.sys.id
License
MIT