Skip to content

Latest commit

 

History

History
65 lines (45 loc) · 2.12 KB

missing-link-properties.md

File metadata and controls

65 lines (45 loc) · 2.12 KB

Missing Link properties

<PrismicLink> requires specific properties in the provided field or document to render properly. This requirement extends to Link, Link to Media, and Content Relationship fields.

If the required properties are missing, <PrismicLink> will not render the link.

Note: When using Prismic's Rest API (the default when using @prismicio/client), the required fields are automatically included. When using Prismic's GraphQL API, you must include these fields in your query.

Required Properties

With the field prop

The following properties are requried when using the field prop with a Link, Link to Media, or Content Relationship field:

  • link_type (or _linkType when using Prismic's GraphQL API)
  • id
  • url
  • uid (only if your website uses a Link Resolver that uses a document's UID field)

The following properties are not required, but are recommended:

  • target

Example:

<PrismicLink field={doc.data.linkField}>Click me</PrismicLink>

With the document prop

The following properties are requried when using the document prop with a Prismic document:

  • id
  • url
  • uid (only if your website uses a Link Resolver that uses a document's UID field)

Example:

<PrismicLink document={doc}>Click me</PrismicLink>

GraphQL Example

When using Prismic's GraphQL API, Link fields must be queried with at least the following properties:

  {
  	page(uid: "home", lang: "en-us") {
  		linkField {
+ 			_linkType
+ 			id
+ 			url
+ 			uid # only required if your website uses a Link Resolver that uses a document's UID field.
+ 			target # not required, but recommended for automatic `target` handling
  		}
  	}
  }