Next.js Discord

Discord Forum

nextjs markdown blog starter kit post rendering for paths

Unanswered
Birman posted this in #help-forum
Open in Discord
BirmanOP
Hi, I'm trying to create my own blog with next js markdown starter kit. While developing a noticed one thing. I'm particularly interested in:
- getStaticPaths
- getStaticProps
I'm i'm not mistaken, the way official vercel nextjs markdown blog starter kit is implemented pages/posts/[slug].tsx has a function getStaticPaths.
This function is implemented in such a way, that it calls getAllPosts function from lib/api . This function creates slug paths, reads files from _posts directory, processes metadata and at the end returns posts data.
In getStaticPaths function after getAllPosts returns data, it is mapped and all files content read from files is discarded and only slug paths are left.
Since this is from official repo, I'm expecting I overlooked something, so my question is, why is there such redundancy, and why slug paths forming logic not separated from file retrieval logic? Why read files just to get those file paths?

0 Replies