@contentful/rich-text-links
    TypeScript icon, indicating that this package has built-in type declarations

    15.0.0 • Public • Published

    rich-text-links

    Entity (entry and asset) link extraction utilities for the Contentful rich text field type.

    Installation

    Using npm:

    npm install @contentful/rich-text-links

    Using yarn:

    yarn add @contentful/rich-text-links

    Usage

    import { getRichTextEntityLinks } from '@contentful/rich-text-links';
    
    const document = {
      nodeType: 'document',
      data: {},
      content: [
        {
          nodeType: 'paragraph',
          data: {},
          content: [
            {
              nodeType: 'embedded-entry-block',
              data: {
                target: {
                  sys: {
                    linkType: 'Entry',
                    type: 'Link',
                    id: 'yXmVKmaDBm8tRfQMwA0e'
                  }
                }
              },
              content: []
            },
            {
              nodeType: 'embedded-asset-block',
              data: {
                target: {
                  sys: {
                    linkType: 'Asset',
                    type: 'Link',
                    id: 'jNhaW0aSc6Hu74SHVMtq'
                  }
                }
              },
              content: []
            },
          ],
        },
      ],
    };
    
    getRichTextEntityLinks(document);
    /**
     * ->
     * {
     *   Entry: [
     *     { linkType: 'Entry', type: 'Link', id: 'yXmVKmaDBm8tRfQMwA0e' }
     *   ],
     *   Asset: [
     *     { linkType: 'Asset', type: 'Link', id: 'jNhaW0aSc6Hu74SHVMtq' }
     *   ]
     * }
     */

    Keywords

    none

    Install

    npm i @contentful/rich-text-links

    DownloadsWeekly Downloads

    7,590

    Version

    15.0.0

    License

    MIT

    Unpacked Size

    37.4 kB

    Total Files

    10

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar