forked from nodejs/nodejs.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblog.tsx
More file actions
50 lines (46 loc) · 1.12 KB
/
Copy pathblog.tsx
File metadata and controls
50 lines (46 loc) · 1.12 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
import { graphql } from 'gatsby';
import React from 'react';
import BlogCard from '../components/BlogCard';
import Layout from '../components/Layout';
import { BlogPostsList } from '../types';
type Props = {
data: BlogPostsList;
};
const AllBlogPosts = ({ data }: Props): JSX.Element => (
<Layout title="Blogs at Nodejs">
<main className="blog-grid-container">
{!data.blogs.edges.length && <h1>No Blog Posts yet</h1>}
{data.blogs.edges.map(node => (
<BlogCard key={node.node.fields.slug} data={node} />
))}
</main>
</Layout>
);
export const pageQuery = graphql`
query AllBlogPostsPageQuery {
blogs: allMdx(
filter: {
fileAbsolutePath: { regex: "/blog/" }
frontmatter: { title: { ne: "mock" } }
}
sort: { fields: [fields___date], order: DESC }
) {
edges {
node {
frontmatter {
title
author {
id
name
}
}
fields {
date(formatString: "MMMM DD, YYYY")
slug
}
}
}
}
}
`;
export default AllBlogPosts;