Reputation: 29
I'm still new in react.I just to make my portfolio built with good tech.I'm interested to gatsbyjs.For now,i got an error.It says
Unknown argument 'frontmatter'
I have no idea about this.Is this related to the graphql or the gatsbyjs?
can someone help me to fix this?
i was watching youtube tutorial from "LevelUp Tutorial" channel.
https://www.youtube.com/watch?v=VxVKMJThh04&list=PLLnpHn493BHHfoINKLELxDch3uJlSapxg&index=5
import React from 'react'
import Helmet from 'react-helmet'
import { graphql } from "gatsby"
export default function Template({ data }) {
const { markdownRemark: post } = data; //sama dengan const post=data.markdownRemark
// const { markdownRemark } = data // data.markdownRemark holds our post data
return (
<div>
<h1>{post.frontmatter.title}</h1>
<div dangerouslySetInnerHTML={{ __html: post.html }} />
</div>
)
}
export const postQuery = graphql`
query BlogPostByPath($path : String!){
markdownRemark(frontmatter:{path: { eq:$path}}){
html
frontmatter{
path
title
}
}
}
Upvotes: 2
Views: 459
Reputation: 39
Go to your gatsby-config.js.
{
resolve: `gatsby-source-filesystem`,
options: {
name: `pages`,
path: `${__dirname}/src/pages`,
},
},
make sure there is(are) *.md file(s) in your pages folder or sub-folders.
That fixed my problem, unknown argument 'frontmatter'. If it does not work for you, check out the tutorial. Creating a Blog with Gatsby
Upvotes: 4