Created
February 26, 2021 21:46
-
-
Save Ekwuno/80a1824a41d0f230f4b162b2717572dc to your computer and use it in GitHub Desktop.
This is the component returns a particular blog post and renders it's content on the screen
This file contains 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 React from "react"; | |
import Layout from "../../components/layout"; | |
import { graphql } from "gatsby"; | |
import { MDXRenderer } from "gatsby-plugin-mdx"; | |
const BlogPosts = ({ data }) => { | |
return ( | |
<Layout> | |
<MDXRenderer>{data.mdx.body}</MDXRenderer> | |
</Layout> | |
); | |
}; | |
export const query = graphql` | |
query ($slug: String) { | |
mdx(slug: { eq: $slug }) { | |
frontmatter { | |
date(formatString: "MM DD YYYY") | |
title | |
} | |
body | |
} | |
} | |
`; | |
export default BlogPosts; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment