Skip to content

sugarshin/routeur

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Super tiny clientside static url router

Resources

Stars

Watchers

Forks

Packages

No packages published