Skip to content

Commit

Permalink
docs: add example for getRichTextResourceLinks to README
Browse files Browse the repository at this point in the history
  • Loading branch information
BasKiers committed Jul 11, 2023
1 parent b50d825 commit a936520
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions packages/rich-text-links/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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',
Expand Down Expand Up @@ -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: [],
},
],
},
],
Expand All @@ -73,4 +86,16 @@ getRichTextEntityLinks(document);
* ]
* }
*/

getRichTextResourceLinks(document, 'embedded-resource-block');
/**
* ->
* [
* {
* linkType: 'Contentful:Entry',
* type: 'ResourceLink',
* id: 'crn:contentful:::content:spaces/6fqi4ljzyr0e/entries/9mpxT4zsRi6Iwukey8KeM'
* }
* ]
*/
```

0 comments on commit a936520

Please sign in to comment.