bitlogist / webity

Advanced Web SSR!
MIT License
4 stars 0 forks source link

Router Locals Mapping #2

Open intfract opened 1 year ago

intfract commented 1 year ago

It would be nice if the Router allowed callback functions or route mapping for server variables. Sometimes, I want different locals to be rendered for every route. Mapping a route to a locals object would be efficient.

new Router(app, {
  '': { x: 'home' },
  'user': (req, res) => { { x: req.params.username } },
})

Dynamic locals can be functions while static locals can simply be plain objects.

bitlogist commented 1 year ago

This will take some time. Route mapping is quite complicated but doable.