From db6600e8b00254aa27f56e20999cc05dd4f411a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20R=C3=B6tsch?= Date: Thu, 14 Jan 2021 13:04:10 +0100 Subject: [PATCH] docs: adjust Contentful Rich Text example codes --- packages/gatsby-source-contentful/README.md | 45 +++++++++++---------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/packages/gatsby-source-contentful/README.md b/packages/gatsby-source-contentful/README.md index ffe1f8546f35b..eddaec6481c07 100644 --- a/packages/gatsby-source-contentful/README.md +++ b/packages/gatsby-source-contentful/README.md @@ -363,29 +363,30 @@ Rich Text feature is supported in this source plugin, you can use the following ### Query Rich Text content and references ```graphql -{ - allContentfulBlogPost { - edges { - node { - bodyRichText { - raw - references { - ... on ContentfulAsset { - contentful_id - fixed(width: 1600) { - width - height - src - srcSet - } - } - ... on ContentfulBlogPost { - contentful_id - title - slug - } +query pageQuery($id: String!) { + contentfulBlogPost(id: { eq: $id }) { + title + slug + # This is the rich text field + bodyRichText { + raw + references { + ... on ContentfulAsset { + contentful_id + __typename + fixed(width: 1600) { + width + height + src + srcSet } } + ... on ContentfulBlogPost { + contentful_id + __typename + title + slug + } } } } @@ -420,7 +421,7 @@ const options = { }, } -function BlogPostTemplate({ data, pageContext }) { +function BlogPostTemplate({ data }) { const { bodyRichText } = data.contentfulBlogPost return
{bodyRichText && renderRichText(richTextField, options)}