fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

add locale to url #110

Closed apapacy closed 1 year ago

apapacy commented 6 years ago

Now I can write

routes
.add('index', '/:lang(ru|en)?', 'index')
.add('about', '/:lang(ru|en)?/about', 'about')
...

It is possible to release?

routes
.add('i18n', '/:lang(ru|en)?/:path?', ':path');

Im try to add custom handler but it work only on server

function customHandler(args) {
  const {req, res, route, query} = args;
  const path = query.path ? query.path : '';
  app.render(req, res, `/${path}`, query);
}

Is the way to customize on client?

fridays commented 6 years ago

Not yet, but it’s a good idea! We could make the page parameter optionally accept a function, that receives the params and returns the page

fridays commented 6 years ago

If anyone wants to look into this right away, changes need to be done here and here

sammdec commented 6 years ago

I would love this funcitonality it looks exactly what I need

petertulala commented 5 years ago

Any update on this?