Skip to content

Commit

Permalink
fix: support nullish slugs property when passing a document to `asL…
Browse files Browse the repository at this point in the history
…ink`
  • Loading branch information
angeloashmore committed Nov 29, 2021
1 parent 42b6b7b commit 85eedea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/documentToLinkField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const documentToLinkField = <TDocument extends PrismicDocument>(
tags: prismicDocument.tags,
lang: prismicDocument.lang,
url: prismicDocument.url ?? undefined,
slug: prismicDocument.slugs[0], // Slug field is not available with GraphQl
slug: prismicDocument.slugs?.[0], // Slug field is not available with GraphQl
// The REST API does not include a `data` property if the data object is empty.
...(Object.keys(prismicDocument.data).length > 0
? { data: prismicDocument.data }
Expand Down

0 comments on commit 85eedea

Please sign in to comment.