UNPKG

@becklyn/contentful-adapter

Version:

[![CI](https://github.com/Becklyn-Studios/contentful-adapter/actions/workflows/ci.yml/badge.svg)](https://github.com/Becklyn-Studios/contentful-adapter/actions/workflows/ci.yml)

22 lines (21 loc) 767 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getHeadlineString = void 0; const rich_text_html_renderer_1 = require("@contentful/rich-text-html-renderer"); const rich_text_types_1 = require("@contentful/rich-text-types"); const getHeadlineString = (data) => { if (!data) { return null; } let paragraphs = []; (0, rich_text_html_renderer_1.documentToHtmlString)(data, { renderNode: { [rich_text_types_1.BLOCKS.PARAGRAPH]: (node, next) => { paragraphs = [...paragraphs, `${next(node.content)}`.split("\n").join("<br/>")]; return ""; }, }, }); return paragraphs.join("<br/>"); }; exports.getHeadlineString = getHeadlineString;