Super tiny clientside static url router
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
src
test
.babelrc
.eslintrc
.gitignore
.travis.yml
README.md
index.js
package.json

README.md

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