forked from devsonket/devsonket.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtop.js
More file actions
49 lines (46 loc) · 1.04 KB
/
Copy pathtop.js
File metadata and controls
49 lines (46 loc) · 1.04 KB
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
import React from "react"
import { StaticQuery, graphql } from "gatsby"
import { Card } from "./common"
import { colors } from "../utils"
export default () => (
<StaticQuery
query={graphql`
query {
allFile(
filter: {
extension: { eq: "json" }
relativeDirectory: { nin: "demo", ne: "draft" }
}
limit: 8
sort: { order: DESC, fields: birthtime }
) {
edges {
node {
id
name
}
}
}
}
`}
render={({ allFile: { edges } }) => {
return edges.map(edge => {
const { id, title, description } = require(`../../data/${
edge.node.name
}.json`)
return (
<Card
id={id}
key={id}
title={title}
description={description}
style={{
backgroundColor:
colors[Math.floor(Math.random() * colors.length)],
}}
/>
)
})
}}
/>
)