Tag Search and Pagination in Next.js

Jan 6, 2020

react

Traverse files on server side#

I found this solution in https://github.com/mxstbr/mxstbr.com/blob/master/data/get-blog-posts.js.

API Routing (Next.js 9.1.7)#

With this new feature, we can create a simle data collection api.

Basically, I move the original solution here and use res.status(200).json() to return the blogs. With this, for pages that should be rendered in the same template, such as pagination, search page, just pass those query parameters like const { tag, page } = req.query and add logic before passing it into json.


Last Edited on Jan 6, 2020