bw-router
bw-router
will allow you to create routes and associate them with a value/object. These values are called
sections as this router was originally designed for bigwheel.
If the this module is running in the browser it will use window.location.hash
to evaluate routes. If it's not
running in an environment where window.location
exists then it will be ignored.
Usage
Example
var bwRouter = require( 'bw-router' );
var router = bwRouter( {
'/': { name: 'landing section' },
'/about': { section: { name: 'about section' }, useURL: false },
'/gallery/:image': { name: 'gallery' },
'/someRedirect': '/about',
'404': { name: '404' }
postHash: '!'
pushState: true,
});
router.init();
router.go( '/gallery/10' );
router.go( '/gallery/10', {silent: true} );
router.destroy();
License
MIT, see LICENSE for details.