Dynamically Add Category Landing Pages with Next.js Dynamic Routes

InstructorColby Fayock

Share this video with your friends

Send Tweet

We will create a new category model where we can reference all of the products that we want in a two-way reference. That means, not only can we reference those products on our category, like we worked on in the previous lesson, we can go the opposite direction on our products node. We will reference those categories and get all the categories that relate to a particular product.

With that data, we will set up a dynamic route for category slug, where we use both getStaticProps and getStaticPaths to build each and every one of those pages, where we will dynamically generate each category page with all the products.

Jason
~ 2 years ago

Same issue here as before with the following message when I try to run the query in graphcms: "message": "input:1: Field "slug" is not defined by type CategoryWhereUniqueInput.\n"

query PageCategory($slug: String) { category(where: {slug: $slug}) { id name slug products { id mainImage name price slug } } }

{ "slug": "t-shirts" }