@@ -16,19 +16,12 @@ function sortPosts(posts: Query['allMarkdownRemark']['edges']) {
16
16
}
17
17
18
18
type QueryType = Query & {
19
- latest : Query [ 'allMarkdownRemark' ]
20
- danielArticle : Query [ 'allMarkdownRemark' ]
21
- elizabethArticle : Query [ 'allMarkdownRemark' ]
22
- mikeArticle : Query [ 'allMarkdownRemark' ]
19
+ articles : Query [ 'allMarkdownRemark' ]
23
20
}
24
21
25
22
export default function News ( ) {
26
23
const data = useStaticQuery < QueryType > ( newsQuery )
27
- const posts = data . latest . edges . concat (
28
- data . danielArticle . edges . concat (
29
- data . elizabethArticle . edges . concat ( data . mikeArticle . edges )
30
- )
31
- )
24
+ const posts = data . articles . edges
32
25
return (
33
26
< div id = "news" className = "ie-fix" css = { styles . container } >
34
27
< h2 > News & Tutorials</ h2 >
@@ -47,7 +40,9 @@ export default function News() {
47
40
date = { post . frontmatter . date }
48
41
header = { post . frontmatter . title }
49
42
to = { post . fields . slug }
50
- type = { author === 'daniel' ? 'Tutorial' : 'Blog' }
43
+ type = {
44
+ post . frontmatter . tags . includes ( 'Tutorial' ) ? 'Tutorial' : 'Blog'
45
+ }
51
46
/>
52
47
)
53
48
} ) }
@@ -92,79 +87,13 @@ const styles = {
92
87
93
88
const newsQuery = graphql `
94
89
query newsQuery {
95
- latest : allMarkdownRemark(
90
+ articles : allMarkdownRemark(
96
91
filter: {
97
92
fileAbsolutePath: { regex: "/blog/" }
98
93
frontmatter: { draft: { ne: true } }
99
94
}
100
- sort: { fields: [frontmatter___date], order: ASC }
101
- limit: 1
102
- ) {
103
- edges {
104
- node {
105
- id
106
- fields {
107
- slug
108
- }
109
- frontmatter {
110
- author
111
- date(formatString: "MMM DD, YYYY")
112
- title
113
- }
114
- }
115
- }
116
- }
117
- danielArticle: allMarkdownRemark(
118
- filter: {
119
- fileAbsolutePath: { regex: "/blog/" }
120
- frontmatter: { draft: { ne: true }, author: { eq: "daniel" } }
121
- }
122
- sort: { fields: [frontmatter___date], order: ASC }
123
- limit: 1
124
- ) {
125
- edges {
126
- node {
127
- id
128
- fields {
129
- slug
130
- }
131
- frontmatter {
132
- author
133
- date(formatString: "MMM DD, YYYY")
134
- title
135
- }
136
- }
137
- }
138
- }
139
- elizabethArticle: allMarkdownRemark(
140
- filter: {
141
- fileAbsolutePath: { regex: "/blog/" }
142
- frontmatter: { draft: { ne: true }, author: { eq: "elizabeth" } }
143
- }
144
- sort: { fields: [frontmatter___date], order: DESC }
145
- limit: 1
146
- ) {
147
- edges {
148
- node {
149
- id
150
- fields {
151
- slug
152
- }
153
- frontmatter {
154
- author
155
- date(formatString: "MMM DD, YYYY")
156
- title
157
- }
158
- }
159
- }
160
- }
161
- mikeArticle: allMarkdownRemark(
162
- filter: {
163
- fileAbsolutePath: { regex: "/blog/" }
164
- frontmatter: { draft: { ne: true }, author: { eq: "mike" } }
165
- }
166
95
sort: { fields: [frontmatter___date], order: DESC }
167
- limit: 1
96
+ limit: 4
168
97
) {
169
98
edges {
170
99
node {
@@ -175,6 +104,7 @@ const newsQuery = graphql`
175
104
frontmatter {
176
105
author
177
106
date(formatString: "MMM DD, YYYY")
107
+ tags
178
108
title
179
109
}
180
110
}
0 commit comments