丰富文本链接
实体(输入和资产)为内容丰富的文本连接提取设施 字段类型.
安装
使用 无数字 :
npm install @contentful/rich-text-links
使用 线条数字 :
yarn add @contentful/rich-text-links
使用量
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' }
* ]
* }
*/