From a936520ae9a18691607aebab336ba24a64a9ad5c Mon Sep 17 00:00:00 2001 From: Bas Kiers Date: Fri, 9 Jun 2023 09:39:48 +0200 Subject: [PATCH] docs: add example for getRichTextResourceLinks to README --- packages/rich-text-links/README.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/rich-text-links/README.md b/packages/rich-text-links/README.md index 76731fcf..237724da 100644 --- a/packages/rich-text-links/README.md +++ b/packages/rich-text-links/README.md @@ -1,6 +1,6 @@ # rich-text-links -Entity (entry and asset) link extraction utilities for the Contentful rich text +Entity (entry and asset) link and ResourceLink extraction utilities for the Contentful rich text field type. ## Installation @@ -20,7 +20,7 @@ yarn add @contentful/rich-text-links ## Usage ```javascript -import { getRichTextEntityLinks } from '@contentful/rich-text-links'; +import { getRichTextEntityLinks, getRichTextResourceLinks } from '@contentful/rich-text-links'; const document = { nodeType: 'document', @@ -56,6 +56,19 @@ const document = { }, content: [], }, + { + nodeType: 'embedded-resource-block', + data: { + target: { + sys: { + linkType: 'Contentful:Entry', + type: 'ResourceLink', + urn: 'crn:contentful:::content:spaces/6fqi4ljzyr0e/entries/9mpxT4zsRi6Iwukey8KeM', + }, + }, + }, + content: [], + }, ], }, ], @@ -73,4 +86,16 @@ getRichTextEntityLinks(document); * ] * } */ + +getRichTextResourceLinks(document, 'embedded-resource-block'); +/** + * -> + * [ + * { + * linkType: 'Contentful:Entry', + * type: 'ResourceLink', + * id: 'crn:contentful:::content:spaces/6fqi4ljzyr0e/entries/9mpxT4zsRi6Iwukey8KeM' + * } + * ] + */ ```