tool-shop-js-router
v0.0.5
Published
JavaScript Library that provides a ready to use router implementation based on NavigoJS.
Downloads
7
Maintainers
Readme
Tool Shop JS Router
This JavaScript library provides an easy to use router for your web application. It's based on Navigo and works best in combination with the Tool Shop JS Widgets.
Get Started
Installation:
Install with NPM using your CLI:
npm install --save tool-shop-js-router
Usage
Example for the usage of the Router:
// Router returns an instance of the Navigo Router
const router = Router({
hooks: {
before(done) {
// ... do something before each page is rendered
done();
}
},
routes: {
"/about": {
page: AboutPage,
// layout is optional. If not set,
// the page is rendered to the body tag directly.
layout: DefaultLayout
},
// default page
"*": {
page: HomePage,
layout: DefaultLayout
}
}
});
API
Page Element
The router instance has a property holding the current page HTML element.
const router = Router(/* ... */);
router.pageElement; // the pages HTML element currently rendered
TODO
- [ ] Pass URL and query params to the page constructor