routeur

1.0.1 • Public • Published

routeur

Build Status Dependency Status GitHub version License

Super tiny clientside static url router

npm i routeur

Usage

import Router from 'routeur';
 
import indexAction from './indexAction';
import pageAction from './pageAction';
 
const routes = {
  '/': indexAction,
  '/page/': [() => {console.log('/page/')}, pageAction],
  '/page2/index.html': [() => {console.log('/page2/index.html')}, pageAction],
  '/page.html': [() => {console.log('/page.html')}, pageAction],
  ['/page2.html']() {
    console.log('/page2.html');
  }
};
 
const router = new Router(routes);
 
router.run();

API

.configure(config)

.run(pathname = location.pathname)

.addRoute(pathname[or route object], action)

.removeRoute(pathname)

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

© sugarshin

Package Sidebar

Install

npm i routeur

Weekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • sugarshin