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
From the course: Master Next.js: Elaborate Hands-On Web Development, React Basics, Advanced Next.js, and Deployment
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
-
-
(Locked)
How to create dynamic routes with Next.js7m 15s
-
(Locked)
getStaticPaths with Next.js implementation5m 14s
-
(Locked)
Mastering dynamic static rendering with Next.js12m 3s
-
(Locked)
Rendering markdown and security vulnerabilities with injected HTML11m 23s
-
(Locked)
Polishing the dynamic post pages10m 43s
-
(Locked)
Polishing a Next.js component with styling7m 22s
-
(Locked)
Fetching data and database querying plus ISR with Next.js11m 26s
-
(Locked)
API routes with Next.js9m 1s
-
(Locked)
-