This repository has been archived by the owner on Jul 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
PostAbbrev.js
83 lines (73 loc) · 1.75 KB
/
PostAbbrev.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
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'gatsby';
import AccessoryInformations from 'components/AccessoryInformations';
import { rhythm } from 'utils/typography';
import TagList from '../TagList';
function PostAbbrev({ slug, title, date, timeToRead, excerpt, tags, base, id, showDisqus }) {
let excerptPart;
if (excerpt) {
excerptPart = (
<p
dangerouslySetInnerHTML={{
__html: excerpt,
}}
/>
);
}
let tagsPart;
if (tags) {
tagsPart = (
<TagList style={{ margin: '0.5rem 0 -0.5rem -0.5rem' }} tags={tags} baseUrl={`${base}tags`} />
);
}
return (
<article>
<header>
<h3
style={{
fontFamily: 'Montserrat, sans-serif',
fontSize: rhythm(1),
marginBottom: rhythm(1 / 4),
}}
>
<Link style={{ boxShadow: 'none' }} to={slug} rel="bookmark">
{title}
</Link>
</h3>
{tagsPart}
<small>
<AccessoryInformations
date={date}
time={timeToRead}
disqus={{
id,
title,
slug,
show: showDisqus,
}}
/>
</small>
{excerptPart}
</header>
</article>
);
}
PostAbbrev.propTypes = {
slug: PropTypes.string.isRequired,
title: PropTypes.string,
date: PropTypes.string.isRequired,
timeToRead: PropTypes.number.isRequired,
excerpt: PropTypes.string,
tags: PropTypes.array,
base: PropTypes.string,
id: PropTypes.string.isRequired,
showDisqus: PropTypes.bool.isRequired,
};
PostAbbrev.defaultProps = {
title: null,
excerpt: null,
tags: null,
base: '',
};
export default PostAbbrev;