Basically I want to define dynamic routes like this:
routes->
/books/categoryname
/books/categoryname/bookId
categoryname is dynamic and also bookId
folder structure:
books ->
index.tsx
[book_category] ->
index.tsx
[id]
index.tsx
how to define dynamic routes in next.config.js ?
next.config.js
exportPathMap: async function (
defaultPathMap,
{ dev, dir, outDir, distDir, buildId }
) {
return {
'/': { page: '/' },
'/about': { page: '/about' },
'/contact': { page: '/contact' },
'/register': { page: '/register' },
'/login': { page: '/login' },
'/books': { page: '/books' },
'/books/category': { page: '/books/[book_category]' },
'/books/category/id': { page: '/books/[book_category]/[id]' },
}
},
}