Skip to content

Commit

Permalink
fix(gatsby-source-contentful): handle nullable fields (#38358)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrysucari authored Jul 21, 2023
1 parent 2e08202 commit 7a2778b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/gatsby-source-contentful/rich-text.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ interface ContentfulRichTextGatsbyReference {
}

interface RenderRichTextData<T extends ContentfulRichTextGatsbyReference> {
raw: string
references: T[]
raw?: string | null
references?: T[] | null
}

export function renderRichText<
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-source-contentful/src/rich-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { documentToReactComponents } from "@contentful/rich-text-react-renderer"
import resolveResponse from "contentful-resolve-response"

export function renderRichText({ raw, references }, options = {}) {
const richText = JSON.parse(raw)
const richText = JSON.parse(raw || null)

// If no references are given, there is no need to resolve them
if (!references || !references.length) {
Expand Down

0 comments on commit 7a2778b

Please sign in to comment.