1
votes

I am learning Gatsby.js right now and I ran into a problem. I have installed transformer plugin and I have a .md file in which I have title,stack and slug.

title :Place Sharing Website
stack :React.js & Node.js
slug :place-sharing
---

### You can share the places that you visited

I want to query that title,stack and slug. But I can't do that. Here is the code I tried to do that.

allMarkdownRemark {
  nodes {
    frontmatter {
      title
      stack
      slug
    }
  }
}
}

it didn't work.

Here is my gatsby.config file

module.exports = {
  plugins: [
    "gatsby-transformer-remark",
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `notes`,
        path: `${__dirname}/src/notes/`,
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `projects`,
        path: `${__dirname}/src/projects/`,
      },
    },
  ],
  siteMetadata: {
    title: "My Homepage",
    description: "This is where I write my thoughts.",
  },
}

Here is how I am trying to query it.

Any idea of what I am doing wrong?

1
There should be --- at the top of the markdown file. Also try going to localhost:PORT/__graphql to see if the markdown file is detected - Akshay
There is --- at the top of the markdown file in my code editor I forgot to add it in the question. No, it is not detected in localhost:8000__graphql. - Nyi Nyi Hmue Aung

1 Answers

0
votes

I think you have formatting issues. Try:

title: Place Sharing Website
stack: React.js & Node.js
slug: place-sharing

And check the creation of the markdown file, the fields should be wrapped inside ---.