prismicio / javascript-kit

Development kit for the Javascript language

Home Page:https://developers.prismic.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I use linked documents?

ghelton opened this issue · comments

I'm trying to pull in some linked documents. I have working queries that provide me with Prismic Documents with linked documents available to me.

{
  fragments: {...},
  linkedDocuments: [...]
  ...
}

I was hoping there would be a method to select linked documents by Id or Name or some other property. I found this while looking for a solution: https://blog.prismic.io/U5nJQCwAAC4ABCJm/improve-your-content-discovery-similar-predicate-and-linked-documents

However the method near the bottom of the article (doc.getLinkedDocument) doesn't seem to exist in the Javascript SDK. If there aren't any features in the sdk to handle this I'll just move on to creating my own lookup, but I thought I would check.

Hi,

The signature differs depending on the kits, and in Javascript it is currently doc.linkedDocuments:
http://prismicio.github.io/javascript-kit/Doc.html

It is a member, not a method.

if you find this sometime in the future, it's been changed:
https://qa.prismic.io/171/why-are-you-releasing-api-breaking-changes-in-the-javascript-kit-and-not-changing-the-major-version-number

Linked Documents are now accessible in the latest SDK as a method rather than a member.

Thanks for the update guys!