/
Posts.js
35 lines (33 loc) · 950 Bytes
/
Posts.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
import React from 'react'
import { Link } from 'gatsby'
import { slugify } from '../utils/helpers'
export default function Posts({ data, tags }) {
return (
<div className={tags ? 'grid posts with-tags' : 'grid posts'}>
{data.map((node) => {
return (
<Link to={node.slug} className="row" key={node.id}>
<div className="cell">
<time>{node.date}</time>
<div>{node.title}</div>
</div>
{tags && (
<div className="cell tags">
{node.tags &&
node.tags.map((tag) => (
<Link
key={tag}
to={`/tags/${slugify(tag)}`}
className={`tag-${tag}`}
>
{tag}
</Link>
))}
</div>
)}
</Link>
)
})}
</div>
)
}