Instructor: I've gone ahead and created pages for each instructor that we have in Contentful. I did the same inaudible as the lesson. Here, we query all the instructors, and then look through the result and create a page for every instructor.
This will be based on the inaudible component, which is the template. I'm simply now displaying the image, the name, and the description. It will be nice if we can display the lessons that are created by this instructor.
Let's check our content modules first. If we go to the lesson, you can see here that every lesson is linking to an instructor, but if we go to an instructor, we have no way of knowing which lesson is made by this instructor.
We could create however a new reference in here and link to a lesson, but this will create a circular dependency, and it's hard to maintain. A better way of doing this is using backreferences that are created by Gatsby in the GraphQL node.
To check that out, let's go to GraphQL and query for all the instructors. In here, we can get the edges, and then the node. We can get things like full name. This is the direct field that belongs to the instructor.
If we type lesson, you can see here that we have access to the lesson, even if it's not linked directly to the instructor in Contentful. Here, we can grab stuff like the title, the image, and so on. Let's do the same in our code and render a list of lessons.
First thing we need to do is to update this query that we already exported. After website, let's add the lesson, get the ID, the title, the slag, and the image. Now that's available for us, let's render it. For that, we need to check first if the lesson is not null. Otherwise, we look through that lesson array and we render it. We will use the same card component that we use in our index page.
Now that's done, let's save and go back again to the instructor page. In here, you can see lessons, and these are all the lessons that are attached to this instructor. We can of course click in here, and this will take us to the lesson detail page that we have.