From the course: Master Next.js: Elaborate Hands-On Web Development, React Basics, Advanced Next.js, and Deployment

Unlock this course with a free trial

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

Mastering dynamic static rendering with Next.js

Mastering dynamic static rendering with Next.js

All right, so let's implement this getStaticPaths now that we have the getStaticPaths set up, and then we should be able to actually see that we can go to these blogs separately. All right, so we want to create more pure functionality. We've got the getSortedPostData, we just created getAllPostId, which just returns the parameters, which is how you would need to do it because that's how getStaticPaths wants to take the inputted data. So, let's do the same thing for getting just the post data by id, right? So, we're going to make another function, which is get post data, which takes id as its input or parameter. And here, we're going to have the, not the fall path, we want to have a full path, as we've done before. So, path.join, we want post directory. But instead of any specific path, we want a template literal string that's going to take that ID, and it's going to be .md, and that's the dynamic input. Then from there, it's going to be able to read the data. That's really the ID…

Contents