GatsbyJS - Adding the display of post’s list in the app
gatsby-source-filesystem (plugin)
This plugin provides the access to app’s file-system. It adds specific nodes in GraphQL scheme of the app
Installation
Install gatsby-source-filesystem in your GatsbyJS app
npm install gatsby-source-filesystem
- set up plugin in gatsby-config.js
|
|
Create the post
Create markdown post in /src/posts, for example greetings.md
GraphQL query of the plugin
gatsby-source-filesystem - How to query (gatsbyjs.com)
Open the GraphQL Editor on http://localhost:8000/__graphql
Example
|
|
Response
|
|
gatsby-transformer-remark (plugin)
This plugin is a markdown parser
Installation
npm:
|
|
yarn:
|
|
In gatsby-config.js:
|
|
After re-run the app you can use new node allMarkdownRemark in GraphQL editor that is provided by the plugin
GraphQL query of the plugin
Query
|
|
- totalCount is the count of markdown files in the app
- edges
- node is each node (file)
- html is html layout of the file
- except the first text of the post’s content with limit
- frontmatter
- title is the parameter that you set in the GatsbyJS > Markdown Metadata
- node is each node (file)
Response
|
|