-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathindex.js
34 lines (29 loc) · 937 Bytes
/
index.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
import React from 'react';
import PropTypes from 'prop-types';
import getSiteHostname from 'utils/getSiteHostname';
import getArticleLink from 'utils/getArticleLink';
import { Item, Card, Image, Content, Title, Source } from './styles';
const GridItem = ({ url, title, id }) => {
const site = getSiteHostname(url) || 'news.ycombinator.com';
const link = getArticleLink({ url, id });
const sourceStr = `// ${site}`;
return (
<a href={link} target="_blank" rel="nofollow noreferrer nofollow">
<Item>
<Card>
<Image src="https://miro.medium.com/max/1176/1*F9RzuXseG1VrTjFJd403gw.png" />
<Content>
<Title>{title}</Title>
<Source>{sourceStr}</Source>
</Content>
</Card>
</Item>
</a>
);
};
GridItem.propTypes = {
url: PropTypes.string,
title: PropTypes.string.isRequired,
id: PropTypes.number.isRequired,
};
export default GridItem;