Skip to content

Commit 279de8f

Browse files
Merge pull request #688 from Financial-Times/content-pipeline-circular-dep
2 parents b7c4075 + b8d5e4b commit 279de8f

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

components/x-live-blog-post/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
"author": "",
1818
"license": "ISC",
1919
"dependencies": {
20-
"@financial-times/cp-content-pipeline-ui": "^0.3.6",
2120
"@financial-times/x-engine": "file:../../packages/x-engine"
2221
},
2322
"devDependencies": {
23+
"@financial-times/cp-content-pipeline-ui": "^0.4.0",
2424
"@financial-times/o-colors": "^6.4.2",
2525
"@financial-times/o-spacing": "^3.2.1",
2626
"@financial-times/o-typography": "^7.2.2",

components/x-live-blog-post/readme.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ Feature | Type | Notes
4545
`postId` | String | Deprecated - Unique id to reference the content
4646
`title` | String | Title of the content
4747
`bodyHTML` | String | Body of the content, if data is from next elasticsearch
48-
`body` | Object | Structured Body of the content, if data is from cp-content-pipeline-api
49-
`byline` | String or Object | Byline for the post, sometimes used to render the author's name. Will be an object if data is from cp-content-pipeline-api
48+
`body` | Object | Structured Body of the content, if data is from `cp-content-pipeline-api`
49+
`byline` | String or Object | Byline for the post, sometimes used to render the author's name. Will be an object if data is from `cp-content-pipeline-api`
50+
| `renderRichText` | Function | A component to use for rendering structured content, e.g. `RichText` from `cp-content-pipeline-ui`. Required when rendering with data from `cp-content-pipeline-api`.
5051
`content` | String | Deprecated - Body of the content
5152
`isBreakingNews` | Bool | When `true` displays "breaking news" tag
5253
`publishedDate` | String | ISO timestamp of publish date
5354
`publishedTimestamp`| String | Deprecated - ISO timestamp of publish date
5455
`articleUrl` | String | Url of the main article that includes this post
5556
`showShareButtons` | Bool | default: `false` - Shows social media share buttons when `true`
56-
`backToTop` | String | Function | Shows the back to top link at the bottom of posts and manages navigating to `selected top` with a javascript function or a hashed href (string). If this prop is a string it will rely on standard browser behaviour to navigate to the element `id` provided that represents the top. If this prop is a function then that function should control the experience of navigating/scrolling to the top position. When using a function please call event.preventDefault() at the top level.
57-
57+
`backToTop` | String or Function | Shows the back to top link at the bottom of posts and manages navigating to `selected top` with a javascript function or a hashed href (string). If this prop is a string it will rely on standard browser behaviour to navigate to the element `id` provided that represents the top. If this prop is a function then that function should control the experience of navigating/scrolling to the top position. When using a function please call event.preventDefault() at the top level.

components/x-live-blog-post/src/LiveBlogPost.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { h } from '@financial-times/x-engine'
22
import ShareButtons from './ShareButtons'
33
import Timestamp from './Timestamp'
4-
import { RichText } from '@financial-times/cp-content-pipeline-ui'
54

65
/**
76
* Triggers a page scroll depending on what the type of `backToTop` is.
@@ -40,6 +39,7 @@ const LiveBlogPost = ({
4039
content, // Remove once wordpress is no longer in use
4140
bodyHTML, //ElasticSearch
4241
body, // cp-content-pipeline
42+
renderRichText: RichText,
4343
publishedTimestamp, // Remove once wordpress is no longer in use
4444
publishedDate,
4545
isBreakingNews, // Remove once wordpress is no longer in use
@@ -54,7 +54,7 @@ const LiveBlogPost = ({
5454

5555
let postBody, postByline
5656

57-
if (body && 'structured' in body) {
57+
if (body && 'structured' in body && RichText) {
5858
// Content comes from cp-content-pipeline-api
5959
postBody = (
6060
<div className="x-live-blog-post__body n-content-body article--body">
@@ -70,7 +70,7 @@ const LiveBlogPost = ({
7070
/>
7171
)
7272
}
73-
if (byline && typeof byline === 'object' && 'tree' in byline) {
73+
if (byline && typeof byline === 'object' && 'tree' in byline && RichText) {
7474
postByline = (
7575
<p className="x-live-blog-post__byline">
7676
<RichText structuredContent={byline} />

components/x-live-blog-post/src/__tests__/LiveBlogPost.test.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { h } = require('@financial-times/x-engine')
22
const { mount } = require('@financial-times/x-test-utils/enzyme')
3+
const { RichText } = require('@financial-times/cp-content-pipeline-ui')
34

45
import { LiveBlogPost } from '../LiveBlogPost'
56

@@ -95,7 +96,8 @@ const regularPostContentPipeline = {
9596
},
9697
publishedDate: new Date().toISOString(),
9798
articleUrl: 'Https://www.ft.com',
98-
showShareButtons: true
99+
showShareButtons: true,
100+
renderRichText: RichText
99101
}
100102

101103
const backToTopPostSpark = {

components/x-live-blog-wrapper/readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ wrapperElement.addEventListener('LiveBlogWrapper.INSERT_POST',
202202
| `showShareButtons` | Boolean | if `true` displays social media sharing buttons in posts |
203203
| `posts` | Array | Array of live blog post data |
204204
| `id` | String | **(required)** Unique id used for identifying the element in the document. |
205+
| `renderRichText` | Component | A component to use for rendering structured content, e.g. `RichText` from `cp-content-pipeline-ui`. Required when rendering with data from `cp-content-pipeline-api`.
205206

206207
## Configuring the `next-live-event-api` endpoint URL.
207208

components/x-live-blog-wrapper/src/LiveBlogWrapper.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class BaseLiveBlogWrapper extends Component {
145145
articleUrl={articleUrl}
146146
showShareButtons={showShareButtons}
147147
ad={ads[index]}
148+
renderRichText={this.props.renderRichText}
148149
/>
149150
))
150151

0 commit comments

Comments
 (0)