Created
September 13, 2018 23:37
-
-
Save mashaal/63a4ae09350d0a575ae85e6d3d112b9a to your computer and use it in GitHub Desktop.
Contentful Cleaner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import traverse from 'traverse' | |
const cleaner = obj => | |
traverse(obj).map(function() { | |
if (this.node.fields && this.node.sys) this.update(this.node.fields) | |
}) | |
export default cleaner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will recursively strip out sys objects, and collapse the field objects. It's a bit easier to work with, and great for nested references.
Original output (with nested references)
Cleaned output