Last active
April 28, 2021 06:35
-
-
Save xiongemi/c8baa1dfeda52a033e14f115abda02b3 to your computer and use it in GitHub Desktop.
blog post archive with material ui
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Grid } from '@material-ui/core'; | |
| import { BlogPost, PostSummary } from '@nx-gatsby-blogs/ui'; | |
| import { graphql } from 'gatsby'; | |
| import React from 'react'; | |
| import { | |
| BlogPostArchivePropsData, | |
| transformBlogPostArchivePropsDataToBlogPosts, | |
| } from './models/blog-post-archive-props-data'; | |
| export interface BlogPostArchiveProps { | |
| data: BlogPostArchivePropsData; | |
| } | |
| export function BlogPostArchive({ data }: BlogPostArchiveProps) { | |
| const posts: BlogPost[] = transformBlogPostArchivePropsDataToBlogPosts(data); | |
| return ( | |
| <Grid container spacing={5}> | |
| {posts.map((post) => { | |
| return ( | |
| <Grid item xs={12} sm={6} md={4} key={post.id}> | |
| <PostSummary post={post}></PostSummary> | |
| </Grid> | |
| ); | |
| })} | |
| </Grid> | |
| ); | |
| } | |
| export default BlogPostArchive; | |
| export const pageQuery = graphql` | |
| query WordPressPostArchive { | |
| allWpPost(sort: { fields: [date], order: DESC }) { | |
| nodes { | |
| id | |
| excerpt | |
| date(formatString: "MMMM DD, YYYY") | |
| title | |
| uri | |
| featuredImage { | |
| node { | |
| altText | |
| localFile { | |
| url | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| `; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment