-
Notifications
You must be signed in to change notification settings - Fork 42
/
article-main-comment.web.js
91 lines (82 loc) · 2.06 KB
/
article-main-comment.web.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import React, { Component } from "react";
import ArticleSkeleton from "@times-components/article-skeleton";
import { getHeadline } from "@times-components/utils";
import ArticleHeader from "./article-header/article-header";
import {
articlePropTypes,
articleDefaultProps
} from "./article-prop-types/article-prop-types";
class ArticlePage extends Component {
constructor(props) {
super(props);
this.renderHeader = this.renderHeader.bind(this);
}
renderHeader() {
const { article } = this.props;
const {
bylines,
expirableFlags,
hasVideo,
headline,
label,
publicationName,
publishedTime,
shortHeadline,
standfirst
} = article;
const authorImage =
bylines &&
bylines.length > 0 &&
bylines[0].image &&
Object.keys(bylines[0].image).length !== 0 &&
bylines[0].image.crop
? bylines[0].image.crop.url
: null;
return (
<ArticleHeader
authorImage={authorImage}
bylines={bylines}
flags={expirableFlags}
hasVideo={hasVideo}
headline={getHeadline(headline, shortHeadline)}
label={label}
publicationName={publicationName}
publishedTime={publishedTime}
standfirst={standfirst}
/>
);
}
render() {
const {
adConfig,
article,
analyticsStream,
error,
isLoading,
logoUrl,
navigationMode,
receiveChildList,
spotAccountId,
paidContentClassName
} = this.props;
if (error || isLoading) {
return null;
}
return (
<ArticleSkeleton
adConfig={adConfig}
analyticsStream={analyticsStream}
data={article}
Header={this.renderHeader}
logoUrl={logoUrl}
receiveChildList={receiveChildList}
navigationMode={navigationMode}
spotAccountId={spotAccountId}
paidContentClassName={paidContentClassName}
/>
);
}
}
ArticlePage.propTypes = articlePropTypes;
ArticlePage.defaultProps = articleDefaultProps;
export default ArticlePage;