0.0.8 • Published 7 years ago

directory-react-routes v0.0.8

Weekly downloads
3
License
MIT
Repository
-
Last release
7 years ago

directory-react-routes

Simple module that translate a directory from a webpack-context to react-router routes.

Eg: a file with the following path: c:/dev/pages/directory/test.jsx where you start your context in: c:/dev/pages/ will get you the route: directory/test

Install

npm install directory-react-routes

Arguments

context

A webpack context, the directory which this context is initiated in will be used as base when building the routes.

filter

A function that will get the component which is about to be added to the route as argument. If the function returns false the component will not be added to the resulting list of routes.

props

A object from whose props all the resulting ruotes will inherit from. Useful if you would like to inject something as a onLoad etc.

Example

var directoryRoutes = require('directory-react-routes');

var context = require.context('./pages/', true, /^(.*\.(jsx$))[^.]*$/igm)

var routes = directoryRoutes(context, function(route) { return route.doAdd }, { onEnter: function() { alert("routed!") } })


<Router>
  {routes}
</Router>
0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago