import React from 'react' import ShareButtons from './ShareButtons' import ShareLinkButton from './ShareLinkButton' import Timestamp from './Timestamp' import RichText from '../RichText' import Expander from '../Expander' import classnames from 'classnames' import Headshot from '../Headshot' import Byline from '../Byline' import RecommendedLivePost from '../content-tree/RecommendedLivePost' import { StructuredTreeFragment } from '@financial-times/cp-content-pipeline-client' /* eslint-disable @typescript-eslint/no-explicit-any */ //TODO: CI-1975 remove "any" types // this has been ported from x-dash, and a lot of what is expected into these arguments will take a lot of digging //TODO: this component isn't adequately 'dumb', split into presentational and logic components type indicators = { isOpinion?: boolean } const TruncatedPost: React.FC> = ({ id, children, }) => { return (
{children}
) } const truncatedSelector = () => { const prefix = '.x-live-blog-post__body >' const selectors = [ 'p', 'blockquote', 'ul', '.o-table-container', '.n-content-recommended--single-story', "[data-layout-name='card']", '.n-content-big-number', 'hr', '.n-content-tweet', "[data-layout-name='timeline']", ] return selectors.map((item) => `${prefix} ${item}`).join(',') } export type LiveBlogPostProps = { id: string postId: string // Remove once wordpress is no longer in use title: string content: string // Remove once wordpress is no longer in use bodyHTML: string //ElasticSearch body: any // cp-content-pipeline publishedTimestamp: string // Remove once wordpress is no longer in use publishedDate: string isPinned: boolean articleUrl: string showShareButtons: boolean showShareLinkButton: boolean byline: StructuredTreeFragment ad: unknown indicators?: indicators authors: Array } const LiveBlogPost: React.FC = ({ id, postId, // Remove once wordpress is no longer in use title, content, // Remove once wordpress is no longer in use bodyHTML, //ElasticSearch body, // cp-content-pipeline publishedTimestamp, // Remove once wordpress is no longer in use publishedDate, articleUrl, showShareButtons = false, showShareLinkButton = false, byline, ad, isPinned, indicators = {}, authors, }) => { let postBody if (body && 'structured' in body) { // Content comes from cp-content-pipeline-api postBody = ( ) } else { // Content comes from next-es or wordpress postBody = (
) // add pinned post old version when comming from next-es or wordpress postBody = isPinned ? (
{postBody}
 
) : ( postBody ) } const author = authors?.[0] ?? null return (
{!author?.headshot && ( )} {author?.headshot && indicators.isOpinion && ( )}
{indicators.isOpinion ? ( Live Opinion ) : isPinned ? ( Editor's pick ) : ( '' )} {!isPinned && ( )}
{showShareLinkButton && ( )}
{title && (

{title}

)} {postBody}
{showShareButtons && ( )}
{ad as any}
) } export { LiveBlogPost }