diff --git a/README.md b/README.md index c96481c..327d2ab 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@
@@ -62,7 +62,54 @@ leafeon.map('docs_', '/docs', [ ]); ~~~ -### API +## Installation (npm) + +~~~bash +$ npm i leafeon +~~~ + +#### Usage + +```js +const leafeon = require('leafeon').Router(); + +leafeon.add('home', '/', function () { + document.write('hello world'); +}).run(); +``` + +## Browser usage + +1. Include leafeon.js in **** or at the end of the **** + +~~~html + + + + +~~~ + +2. Init the router + +~~~js +const leafeon = new leafeon.Router(); +~~~ + +3. Create some routes and run the router + +~~~js +leafeon + .add('home', '/', () => { /* ... */ }) + .add('contact', '/contact', () => { /* ... */ }) + .setErrorCallback(() => { /* ... */ }) + .run(); +~~~ + +## Browser support + +Supports IE 11+, Chrome 43+, Opera 29+, and Firefox 41+ + +## API #### `.add(name: string, path: string, callback: function)` @@ -130,53 +177,6 @@ Register a middleware that will be executed before given path. Type **`*`** to t Run the router with registered routes. Optionally, register a middleware that will be executed after every routes callback. -## Installation (npm) - -~~~bash -$ npm i leafeon -~~~ - -#### Usage - -```js -const leafeon = require('leafeon').Router(); - -leafeon.add('home', '/', function () { - document.write('hello world'); -}).run(); -``` - -## Browser usage - -1. Include leafeon.js in **** or at the end of the **** - -~~~html - - - - -~~~ - -2. Init the router - -~~~html -const leafeon = new leafeon.Router(); -~~~ - -3. Create some routes and run the router - -~~~js -leafeon - .add('home', '/', () => { /* ... */ }) - .add('contact', '/contact', () => { /* ... */ }) - .setErrorCallback(() => { /* ... */ }) - .run(); -~~~ - -## Browser support - -Supports IE 11+, Chrome 43+, Opera 29+, and Firefox 41+ - ## License This repository is MIT licensed.