contentful-migration
Version:
Migration tooling for contentful
21 lines • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEnabledResourceLinkNodes = exports.isResourceLink = exports.RICH_TEXT_RESOURCE_LINK_NODES = exports.MAX_RESOURCE_LINKS = exports.MAX_ALLOWED_RESOURCES = void 0;
exports.MAX_ALLOWED_RESOURCES = 20;
exports.MAX_RESOURCE_LINKS = 3;
exports.RICH_TEXT_RESOURCE_LINK_NODES = ['embedded-resource-block'];
const isResourceLink = (field) => { var _a; return field.type === 'ResourceLink' || (field.type === 'Array' && ((_a = field.items) === null || _a === void 0 ? void 0 : _a.type) === 'ResourceLink'); };
exports.isResourceLink = isResourceLink;
const getEnabledResourceLinkNodes = (field) => {
if (field.type !== 'RichText' || !Array.isArray(field.validations)) {
return [];
}
for (const { enabledNodeTypes } of field.validations) {
if (Array.isArray(enabledNodeTypes)) {
return exports.RICH_TEXT_RESOURCE_LINK_NODES.filter((nodeType) => enabledNodeTypes.includes(nodeType));
}
}
return [];
};
exports.getEnabledResourceLinkNodes = getEnabledResourceLinkNodes;
//# sourceMappingURL=resource-links.js.map