forked from devsonket/devsonket.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAllItems.js
More file actions
75 lines (69 loc) · 1.67 KB
/
Copy pathAllItems.js
File metadata and controls
75 lines (69 loc) · 1.67 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
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
import React from "react"
import { StaticQuery, graphql } from "gatsby"
import styled from "@emotion/styled"
import Items from "./Items"
import { Card } from "../common"
import { organizedData } from "../../utils"
const ContentContainer = styled.div`
margin-bottom: 25px;
.items {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
> * {
width: calc(100% / 3 - 10px);
margin-right: 15px;
@media (min-width: 769px) {
:nth-child(3n + 3) {
margin-right: 0;
}
}
@media (max-width: 768px) {
width: calc(100% / 2 - 10px);
:nth-child(2n + 2) {
margin-right: 0;
}
}
@media (max-width: 480px) {
width: calc(100%);
margin-right: 0;
}
}
`
const AllItems = () => (
<Items title="সবগুলো">
<StaticQuery
query={graphql`
query {
allFile(
filter: {
extension: { eq: "json" }
relativeDirectory: { nin: "demo", ne: "draft" }
}
limit: 1000
) {
edges {
node {
id
name
}
}
}
}
`}
render={({ allFile: { edges } }) =>
Object.keys(organizedData(edges)).map((char, index) => (
<ContentContainer key={index}>
<h3>{char}</h3>
<div className="items">
{organizedData(edges)[char].map(({ id, title }) => (
<Card key={id} id={id} title={title} />
))}
</div>
</ContentContainer>
))
}
/>
</Items>
)
export default AllItems