How to use the @times-components/markup-forest.renderTreeAsText function in @times-components/markup-forest

To help you get started, we’ve selected a few @times-components/markup-forest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github newsuk / times-components / packages / article-skeleton / src / head.web.js View on Github external
const { bylines } = article;

  if (!bylines) {
    return null;
  }

  const children = bylines.reduce((acc, byline) => {
    if (Array.isArray(byline.byline)) {
      acc.push(...byline.byline);
    } else {
      acc.push(byline.byline);
    }
    return acc;
  }, []);

  return renderTreeAsText({ children });
}
github newsuk / times-components / packages / article-skeleton / src / head.web.js View on Github external
const {
    descriptionMarkup,
    headline,
    leadAsset,
    publicationName,
    shortHeadline,
    publishedTime,
    updatedTime,
    hasVideo
  } = article;

  const publication = PUBLICATION_NAMES[publicationName];
  const authorName = getAuthorAsText(article);
  const desc =
    Array.isArray(descriptionMarkup) && descriptionMarkup.length
      ? renderTreeAsText({ children: descriptionMarkup })
      : null;
  const sectionname = getSectionName(article);
  const leadassetUrl = appendToUrl(
    getArticleLeadAssetUrl(article),
    "resize",
    685
  );
  const caption = get(leadAsset, "caption", null);
  const title = headline || shortHeadline || "";
  const datePublished = new Date(publishedTime).toISOString();
  const dateModified = updatedTime || datePublished;
  const thumbnailUrl = hasVideo
    ? getVideoLeadAssetUrl(article)
    : getThumbnailUrlFromImage(article);

  const jsonLD = {

@times-components/markup-forest

Utility functions for traversing The Times' AST

BSD-3-Clause
Latest version published 7 months ago

Package Health Score

80 / 100
Full package analysis