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.

getStaticPaths with Next.js implementation

getStaticPaths with Next.js implementation

Okay, so let's keep working on setting up dynamic routes. So let's go into our library in our posts where we were creating these functions that help us to deal with the blog post data. So we've got getSortedPostData as one. Now, we could create another function, which we can call getAllPostIds, which can get us essentially that, all the post IDs. Now, we're doing it in getSortedPostData, but that's for a specific purpose of getting the post data that we wanted to demonstrate before and sorting it. So this is really a function to sort. So pure functional programming with utilities, we're not gonna start messing up all our functions and getting confused. We're gonna create another function that serves the pure purpose of getting all post IDs, all right? And it's gonna be the same thing, constant file names. We're gonna go fs.read file sync, which we've explained previously, post directory, and basically in the last section. So we're using the file system to then read from our posts…

Contents