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
From the course: Master Next.js: Elaborate Hands-On Web Development, React Basics, Advanced Next.js, and Deployment
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…
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)
-