This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
/
index.js
67 lines (63 loc) · 1.51 KB
/
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
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
import React from 'react'
import Link from 'next/link'
import { connect } from 'redux-bundler-react'
import ReactMarkdown from 'react-markdown'
const BadConnection = (
<div
style={{
minHeight: '350px',
display: 'flex',
flexDirection: 'column',
justifyContent: 'center'
}}
>
<h1>Connection Error</h1>
<p>
We ran into some issues fetching our blog. Feel free to refresh the page.
</p>
</div>
)
const ListItem = ({
title,
url,
urlSlug,
markup,
description,
image,
date,
creator
}) => {
return description ? (
<div style={{ maxWidth: '700px', paddingBottom: '80px' }}>
<Link
prefetch
as={`/blog/${urlSlug}`}
href={`/blog/single?slug=${urlSlug}`}
>
<a>
<h3 style={{ margin: '20px 0 0 0' }}>{title}</h3>
</a>
</Link>
<ReactMarkdown source={description} />
<Link
prefetch
as={`/blog/${urlSlug}`}
href={`/blog/single?slug=${urlSlug}`}
>
<a style={{ display: 'flex', border: 'none' }}>
<h6 style={{ margin: 0 }}>{date}</h6>
<div style={{ width: '1px', background: '#211f6d', margin: '0 15px' }}/>
<h6 style={{ margin: 0 }}>{creator.name}</h6>
</a>
</Link>
</div>
) : null
}
const BlogList = connect(
'selectBlogPosts',
({ blogPosts }) =>
blogPosts && blogPosts.length
? blogPosts.map((post, i) => <ListItem {...post} key={i} />)
: BadConnection
)
export { BlogList, BadConnection }