From ff5657d6c52abdfa7c39d27300bb64a8593e47df Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 15 May 2019 14:46:52 +0200 Subject: [PATCH] Docs: ToC & npm usage for ES6 --- README.md | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3e8c8f7..43110ea 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,26 @@

+## Table of Content + +- [Features](#features) +- [Overview](#overview) +- [Usage](#usage) + - [npm](#npm) + - [Browser](#browser) +- [Browser support](#browser-support) +- [API](#api) + - [`.add(name: string, path: string, callback: function)`](#addname-string-path-string-callback-function) + - [`.map(prefixName: string, prefixPath: string, routes: Array)`](#mapprefixname-string-prefixpath-string-routes-array) + - [`.fetchRoute(name: string[, parameters: object])`](#fetchroutename-string-parameters-object) + - [`.route: object`](#route-object) + - [`.setErrorCallback(callback: function)`](#seterrorcallbackcallback-function) + - [`.notFoundException()`](#notfoundexception) + - [`.before(path: string, callback: function)`](#beforepath-string-callback-function) + - [`.run([callback: function])`](#runcallback-function) +- [License](#license) + + ## Features - Dynamic routing & URL generator @@ -80,23 +100,30 @@ leafeon.map('docs_', '/docs', [ ]); ~~~ -## Installation (npm) +## Usage + +#### npm + +Install the package : ~~~shell -npm install leafeon +npm i leafeon --save ~~~ -#### Usage - ```js const leafeon = require('leafeon').Router(); +// or using ES6 +// import * as leafeon from 'leafeon'; +// const router = leafeon.Router(); -leafeon.add('home', '/', function () { +leafeon.add('home', '/', () => { document.write('hello world'); -}).run(); +}) + +leafeon.run(); ``` -## Browser usage +### Browser 1. Include leafeon.js in **** or at the end of the ****