prismicio / prismic-react

React components and hooks to fetch and present Prismic content
https://prismic.io/docs/technologies/homepage-reactjs
Apache License 2.0
154 stars 41 forks source link

Is there a way of pushing more data to the link resolver? #76

Closed jodiedoubleday closed 2 years ago

jodiedoubleday commented 3 years ago
<RichText
  render={myDoc.data.title}
  linkResolver={linkResolver}
 />

linkResolver in this instance takes the _meta information for the inline link (uses UID as the resolver) however in my project in using a slug.

is there a way I can pass more data into the link resolver so that it uses slug to resolve?

example of graphQL:


... on PRISMIC_Page {
  _meta {
    uid
    type
    tags
    lang
  }
  slug
}
angeloashmore commented 2 years ago

Hey @jodiedoubleday, sorry you didn't get a reply sooner. This comment comes almost a year and a half late. 🙃

If you are still looking for an answer, the answer is no, unfortunately. When using Prismic's GraphQL API, you are unable to fetch additional data for links within a Rich Text Field.

This limitation is only specific to document links in Rich Text fields rendered with <RichText> (which is now replaced by <PrismicRichText>. If you query for a document (i.e. not a Rich Text field) and pass it to <PrismicLink>, then you will have access to any data requested in your query.

When using Prismic's Rest API V2, you can specify nested content in a Rich Text field using GraphQuery or fetchLinks. These options will include nested data within any link field or within any links in a Rich Text field.

I'm going to close this issue, but please feel free to reply if you have any more questions. Thanks!