import React, { useEffect } from "react" import { graphql } from "gatsby" import Layout from "../components/layout" import { MDXRenderer } from "gatsby-plugin-mdx" export default function Template({ data, // this prop will be injected by the GraphQL query below. }) { const { mdx } = data // data.markdownRemark holds your post data const { frontmatter, body } = mdx useEffect(() => { document.title = frontmatter.title }, [frontmatter.title]) return ( {body} ) } export const pageQuery = graphql` query($path: String!) { mdx(frontmatter: { path: { eq: $path } }) { body frontmatter { title } } } `