-
Notifications
You must be signed in to change notification settings - Fork 229
/
index.jsx
90 lines (86 loc) · 2.45 KB
/
index.jsx
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
import React, { useContext } from 'react';
import path from 'ramda/src/path';
import styled from 'styled-components';
import { articleDataPropTypes } from '#models/propTypes/article';
import ArticleMetadata from '../ArticleMetadata';
import { ServiceContext } from '#contexts/ServiceContext';
import headings from '../Headings';
import text from '../Text';
import image from '../Image';
import Blocks from '../Blocks';
import timestamp from '../ArticleTimestamp';
import { GhostGrid } from '#lib/styledGrid';
import ATIAnalytics from '../ATIAnalytics';
import ChartbeatAnalytics from '../ChartbeatAnalytics';
import articleMediaPlayer from '../ArticleMediaPlayer';
import LinkedData from '../LinkedData';
import {
getArticleId,
getHeadline,
getSummary,
getFirstPublished,
getLastPublished,
getAboutTags,
getArticleSection,
getMentions,
getLang,
} from './utils';
const componentsToRender = {
headline: headings,
subheadline: headings,
audio: articleMediaPlayer,
video: articleMediaPlayer,
text,
image,
timestamp,
};
const StyledMain = styled.main`
flex-grow: 1;
`;
const ArticleMain = ({ articleData: data }) => {
const { articleAuthor } = useContext(ServiceContext);
const headline = getHeadline(data);
const description = getSummary(data) || getHeadline(data);
const firstPublished = getFirstPublished(data);
const lastPublished = getLastPublished(data);
const aboutTags = getAboutTags(data);
return (
<>
<ATIAnalytics data={data} />
<ChartbeatAnalytics data={data} />
<ArticleMetadata
articleId={getArticleId(data)}
title={headline}
author={articleAuthor}
firstPublished={firstPublished}
lastPublished={lastPublished}
section={getArticleSection(data)}
aboutTags={aboutTags}
mentionsTags={getMentions(data)}
lang={getLang(data)}
description={description}
/>
<LinkedData
showAuthor
type="Article"
seoTitle={headline}
headline={headline}
datePublished={firstPublished}
dateModified={lastPublished}
aboutTags={aboutTags}
/>
<StyledMain role="main">
<GhostGrid>
<Blocks
blocks={path(['content', 'model', 'blocks'], data)}
componentsToRender={componentsToRender}
/>
</GhostGrid>
</StyledMain>
</>
);
};
ArticleMain.propTypes = {
articleData: articleDataPropTypes.isRequired,
};
export default ArticleMain;