Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby-source-contentful): enable RichText for all users #10301

Merged
merged 2 commits into from
Dec 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions packages/gatsby-source-contentful/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,20 @@ like the following:

## **Beta** [Contentful Rich Text](https://www.contentful.com/developers/docs/concepts/rich-text/)

If you want to use the new Rich Text feature you can opt-in by setting the following environment variable:
Rich text feature is supported in this source plugin, if you want to serialize the field content to html you can add the plugin `@contentful/gatsby-transformer-contentful-richtext`.

```sh
export GATSBY_CONTENTFUL_RICH_TEXT='enabled'
After adding the transformer plugin you can use the following query to get the html output:

```
{
allContentfulBlogPost {
bodyRichText {
childContentfulRichText {
html
}
}
}
}
```

[dotenv]: https://github.com/motdotla/dotenv
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby-source-contentful/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ exports.createContentTypeNodes = ({
delete entryItemFields[entryItemFieldKey]
} else if (
fieldType === `RichText` &&
process.env.GATSBY_CONTENTFUL_RICH_TEXT === `enabled` &&
_.isPlainObject(entryItemFields[entryItemFieldKey])
) {
const richTextNode = prepareStructuredTextNode(
Expand Down