From the course: Learning Next.js

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Pre-rendering at build time with static paths

Pre-rendering at build time with static paths

From the course: Learning Next.js

Pre-rendering at build time with static paths

- [Instructor] We continue with the example of getStaticPath, and what we're going to be doing here is to allow to statically generate content that we're going to use, depending on the path that we navigate to. So, I'm going to be using a switch case. And this switch case will take, actually, remember that we're using dynamic routes. So we're using this here placeholder. So we're going to access this one params query from params, so that it's going to be params.path, like this. And inside the switch case, we're going to have two case. First, one that corresponds to a predefined path, which is top stories. And another one which is to display the popular stories. And no. So that's actually here, the two dots. And after that, you can return to whichever results you get back from the API call. So we're going to return this with the object, props. Same here for the popular. And for any switch case, you always have a default…

Contents