The dev.to project with GatsbyJS-8

Welcome to part-8 of the series. You can find part-7 here.

Now, it’s time to generate those pages programatically, when we click on the Read More button.

First create a file post-template.js file inside the templates folder. Let’s do all the necessary imports required in it first.

Image for post
Image for post
post-template.js

Rest of the chapter is exclusive content and will be in my upcoming book Gatsby Cookbook. You can find more details about it here.

Image for post
Image for post

Now, we will first write the GraphQL query to get the single post. Here, we are using mdx and passing a slug to it. In the playground we are using Query Variables to pass a slug.

Image for post
Image for post
Single Post

This completes part-8 of the series. You can find part-9 here.

You can find the code for the same in this github repo.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store