~1.5kb gzipped
import { Router } from "simple-ts-router";
const router = new Router();
const title = <HTMLHeadingElement>document.querySelector("#title");
router
.add("/blog/:id/post/:postid", ({ id, postid }) => {
title.innerText = `blog ${id} : ${postid}`;
})
.add("/", () => {
title.innerText = "home";
})
.add("_404", () => {
title.innerHTML = "404";
})
.check();
import { Router } from "https://cdn.skypack.dev/simple-ts-router?min";
const router = new Router();
const title = <HTMLHeadingElement>document.querySelector("#title");
router
.add("/blog/:id/post/:postid", ({ id, postid }) => {
title.innerText = `blog ${id} : ${postid}`;
})
.add("/", () => {
title.innerText = "home";
})
.add("_404", () => {
title.innerHTML = "404";
})
.check();