Programmatically create pages from data.
Ha, first paragraph today of the tuturoal, ” you don’t want to just see excerpts, you want actual pages for your markdown files”. Guess I know just what we’ll be doing already!
Today we’re building up the logic to take markdown files and make actual html pages out of them. We’ve started by making a new file at the root of the project and named it gatsby-node.js . Then we start with my favorite practice of console.logging the snot out of everything. You know, just to make sure we’re getting the data we expect. Then we really start doing some neat stuff by building the pages. Read about it here.
Following further along we’ll build out a new template, this time we make a folder called templates, then make a blog-post.js template page. We use that back over in gatsby-node.js
As you might have read before, you’ll remember that I like to type out each line of code that I’m going through in the tutorials. Why? I think it helps me understand better what I’m doing. I have to read what I’m typing out, and you know, type it. This is useful, but also error prone..
What you’ll notice in the screenshot below is two nearly identical lines. I have taken to copying each line over, and pasting it above the line I typed out. This practice helps me troubleshoot where I mistyped. As you can see I’m the worst at spelling.
Now that we’ve got that working as expected, we should start seeing some pages that represent our two markdown files. pandas-and-bananas/
Now that we have those pages building out as pages, we can update our test page from yesterday to actually link to the pages.
Aaaaand we have two fancy md page Descriptions being returned on our example page from yesterday. But now we can click on the links, and see real for real pages!
Really cool stuff. I know its not quite on the same level as creating all this type of work on your own, but folloing along with the tutorials is awsome.