Skip to content

Instantly share code, notes, and snippets.

@Ekwuno
Created February 26, 2021 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ekwuno/80a1824a41d0f230f4b162b2717572dc to your computer and use it in GitHub Desktop.
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
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