-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs/add markdown page #3111
Docs/add markdown page #3111
Conversation
docs/docs/adding-markdown-pages.md
Outdated
|
||
1. Read files in Gatsby from the filesystem. | ||
2. Understand Markdown syntax. Convert metadata to api and content to html. | ||
3. Create a page template from above Markdown data and style it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"from" should be "for" to match heading below?
Deploy preview ready! Built with commit 9b21069 |
Deploy preview ready! Built with commit 4c5a1c9 |
docs/docs/adding-markdown-pages.md
Outdated
} | ||
|
||
export const pageQuery = graphql` | ||
query BlogPostByPath($path: String!) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you offer just a little more about who / how the $path
variable is getting filled in? I thought it would get set in the context
parameter in gatsby-node.js
but I don't see it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review!
So that's a graphQL thingy which I don't completely understand honestly :(
Regardless, wouldn't the right thing to do be point to graphQL docs or graphQL-Gatsby docs at this stage? It would be awfully irrelavant explaining graphQL query structure here no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't mean explain how graphql variables work, I mean specifically what sets the value for that $path
variable. If that's a standard thing that's explained somewhere else, then a pointer would be good. I haven't found a place it's explained, though. I only figured out some of how they work by reading code in the examples (gatsbygram in particular).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I really want to say thank you for writing this, it's already helped me a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry for the delay. I really am only trying this out on the weekend. Thanks for the encouragement. Will finish this up soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tamouse - I tried figuring this out. I think I have an idea that possibly some Gatsby Node-api magic is involved, but can't say for sure. Would really love somebody's help on this. Maybe @KyleAMathews can help me with this part of the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tayiorbeii talks about this in https://egghead.io/lessons/gatsby-create-a-blog-post-template-for-gatsby .Maybe he can help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi pksjce! Thanks for submitting this PR! We're excited! I'm helping Kyle Mathews out with docs and will probably be making a few reviews of this file (usually it will be edits for grammar and style rather than actual coding knowledge--so please correct me if I'm wrong!).
docs/docs/adding-markdown-pages.md
Outdated
This is a stub. Help our community expand it. | ||
Gatsby can easily convert Markdown pages to static pages in your site. | ||
It provides plugins to read and understand folders with markdown files and | ||
node api, which help you create static pages automatically. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My initial feedback is to make sure you write API with all caps. And are you referring to Node.js API? Because if so, then Node.js is capitalized too.
docs/docs/adding-markdown-pages.md
Outdated
Here's how you do it step by step. | ||
|
||
1. Read files in Gatsby from the filesystem. | ||
2. Understand Markdown syntax. Convert metadata to api and content to html. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe HTML is also in all caps.
docs/docs/adding-markdown-pages.md
Outdated
|
||
#### Note on creating markdown files. | ||
|
||
When you create a Markdown file, you can add a block that looks like below to the top of the file content. This block will be parsed by `gatsby-transformer-remark` as `frontmatter`. The GraphQL api will provide this data in our React components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"that looks like the block below"
docs/docs/adding-markdown-pages.md
Outdated
|
||
Gatsby exposes a powerful Node API, which allows for functionality such as creating dynamic pages. This API is exposed in the `gatsby-node.js` file in the root directory of your project, at the same level as `gatsby-config.js`. Each export found in this file will be parsed by Gatsby, as detailed in its [Node API specification](https://www.gatsbyjs.org/docs/node-apis/). However, we only care about one particular API in this instance, `createPages`. | ||
|
||
Gatsby calls the `createPages` api (if present) at build time with injected parameters, `boundActionCreators` and `graphql`. Use the `graphql` to query Markdown file data as below. Next use `createPage` action creator to create a page for each of the Markdown files using the `blogTemplate.js` we created in the previous step. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"to query Markdown file data as shown below"
docs/docs/adding-markdown-pages.md
Outdated
``` | ||
|
||
Two things are important in the file above. | ||
1. A GraphQL query is made in the second half of the file to get the markdown data. Gatsby has automagically given you all the Markdown metadata and html in this query's result. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe Markdown is always capitalized as well.
docs/docs/adding-markdown-pages.md
Outdated
Now open up your `gatsby-config.js` to add this plugin to the plugin list. | ||
|
||
The plugin list accepts either a string which is the plugin name or an object with any options you may want to pass. | ||
Here we add an object with the path as an option to the plugin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is missing punctuation, like a period or colon at the end.
Hey @shannonbux - I've made the grammatical corrections! |
Thanks @pksjce and the reviewers! |
Yay! Thanks! |
Hey @KyleAMathews - How would I fix the indentation here? |
Fixed it in another PR actually :-) it's in the docs-links.yaml file for future reference |
Cool! In my next PR will remember to do that too. |
Hiya @pksjce! 👋 This is definitely late, but on behalf of the entire Gatsby community, I wanted to say thank you for being here. Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If you have questions, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! 💪💜 |
This is just a stripped down reproduction of https://www.gatsbyjs.org/blog/2017-07-19-creating-a-blog-with-gatsby/ with generalised terms and actionable steps. I found that this was the minimum setup I required to get my blog working.
Also in the context is https://www.gatsbyjs.org/blog/2017-11-08-migrate-from-jekyll-to-gatsby/