[RFC] Add standard frontmatter transforms to netlify cms plugin #10478
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When trying to work with the Netlify CMS plugin, I ran into an issue with images like #8195. I found it odd that I had to manually transform the image paths to relative paths to make them compatible with the gatsby-transformer-sharp plugin.
I think it's safe to assume that anyone working with the Netlify CMS will want to process their images for resizing and such, otherwise you would be missing a big part of what makes Gatsby perform great.
In this PR I have pulled the code for transforming images and some other standard tasks like creating a slug into the plugin code.
I have added two config options for the plugin:
contentFolder: This would be the root folder where all of your Netlify content lives, which defaults to "content".imageFields: A list of frontmatter fields that hold paths to images. These fields will be transformed to relative paths.Now that I think of it,
imageFieldsshould maybe be renamed toassetFieldsormediaFieldssince I assume that you'd want to same transformation if you use other types of assets in the CMS.Of course the docs would need to be updated also, but first I'm curious to get some feedback and verify if this is all a good idea to begin with.
With these changes you can start using the CMS without writing additional client code in
gatsby-node.js, which is I think how a plugin should work ideally.