From 3473b02fd34ba371d6a38bc243d81430241ca5a1 Mon Sep 17 00:00:00 2001 From: Khaled Garbaya Date: Wed, 5 Dec 2018 13:41:48 +0100 Subject: [PATCH 1/2] Enable RichText for all users --- packages/gatsby-source-contentful/src/normalize.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/gatsby-source-contentful/src/normalize.js b/packages/gatsby-source-contentful/src/normalize.js index 942836833f856..70f61375271c7 100644 --- a/packages/gatsby-source-contentful/src/normalize.js +++ b/packages/gatsby-source-contentful/src/normalize.js @@ -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( From 79ddbbcd394295cf0951e8f0da0536d7f04ee836 Mon Sep 17 00:00:00 2001 From: Khaled Garbaya Date: Wed, 5 Dec 2018 14:05:33 +0100 Subject: [PATCH 2/2] chore: Update README --- packages/gatsby-source-contentful/README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/gatsby-source-contentful/README.md b/packages/gatsby-source-contentful/README.md index d98ed8c9692e5..a20bb541d4796 100644 --- a/packages/gatsby-source-contentful/README.md +++ b/packages/gatsby-source-contentful/README.md @@ -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