Skip to content

Palladium02/js-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JS-Router

Typescript

JS-Router is a very simple routing system build with Typescript.

Languages

Prologue

I highly recommend the installation of es6-string-html, when using VSCode.

Creating a router instance

const router = new Router();

Parameter

name type default description
selector String null selector for root element
history Boolean false enables navigation with browser control elements
debug Boolean false enables debug messages in the console

Adding pages

import home from 'relative/path/to/component.js';
router.get('/home', home);

'home' represents the components that should be rendered when clicking the corresponding link.

Components

export default () => {
    /*html*/`
        <div>
        
        </div>
    `
}

Links

<div data-link="/home">Home</div>

Links can be represented through every HTML-element. The link element has to have the data-link attribute.