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

fix(gatsby-source-contentful): handle nullable fields #38358

Merged
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
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