-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.tsx
106 lines (101 loc) · 3.53 KB
/
index.tsx
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import * as React from 'react'
import {graphql, Link} from "gatsby"
import Layout from "../components/layout";
import Container from "../components/container";
import PostHeader from "../components/post-header";
import PostItems from "../components/post-items";
import SEO from "../components/seo";
export default function IndexPage({data}) {
const posts = data?.allMarkdownRemark?.edges || [];
const pinned = data?.markdownRemark || null;
const totalCount = data?.allMarkdownRemark?.totalCount;
return (
<Layout>
<SEO title={`خانه`} description={"برترین مطالب برای برترین ها"} />
<Container>
{pinned && (
<PostHeader
timeToRead={pinned?.timeToRead}
datetime={pinned?.frontmatter?.datetime}
author={pinned?.frontmatter?.author}
to={`/${pinned.frontmatter?.slug}`}
title={pinned.frontmatter?.title}
image={pinned.frontmatter?.thumbnail?.childImageSharp.fluid}
variant={"link"}
category={pinned?.frontmatter?.category}
/>
)}
<PostItems posts={posts}/>
{totalCount >= 6 && (
<div className={"py-20 flex items-center"}>
<Link to={"/posts"} className={"mx-auto rounded-md bg-blue-200 text-blue-600 px-8 py-3"}>
همه مطالب
</Link>
</div>
)}
</Container>
</Layout>
)
}
export const query = graphql`
query {
markdownRemark(frontmatter: {pinned: {eq: true}}) {
timeToRead
frontmatter {
title
datetime
slug
category {
name
id
}
author {
name
id
image {
childImageSharp {
fixed(width: 100) {
...GatsbyImageSharpFixed
}
}
}
}
thumbnail {
childImageSharp {
fluid{
...GatsbyImageSharpFluid
}
}
}
}
}
allMarkdownRemark(limit: 6, filter: {frontmatter: {type: {eq: "post"}}}) {
totalCount
edges {
node {
timeToRead
frontmatter {
datetime
title
category {
name
id
}
slug
author {
name
id
}
thumbnail {
childImageSharp {
fixed(width: 300){
...GatsbyImageSharpFixed
}
}
}
}
}
}
}
}
`;