diff --git a/src/core/router.ts b/src/core/router.ts index b159789..eb4b49b 100644 --- a/src/core/router.ts +++ b/src/core/router.ts @@ -1,4 +1,5 @@ import { EVENT_BUS } from "./"; +import {buildErrorPage} from "../views/error404.ts"; type RouteHandler = (params?: Record) => void; @@ -27,6 +28,7 @@ class Router { return; } } + buildErrorPage(); console.error(`No handler found for path: ${path}`); } diff --git a/src/views/error404.ts b/src/views/error404.ts index 4605c92..3410f92 100644 --- a/src/views/error404.ts +++ b/src/views/error404.ts @@ -1,4 +1,17 @@ - -export function buildErrorPage() { +import {writeTitle} from "./utils"; +import {renderView} from "./index.ts"; + + +function errorView() { + const article = document.createElement('article'); + const viewTitle = writeTitle("h1", "Page not found 404"); + article.appendChild(viewTitle); + return article; +} + +//----------------------------------------------------------------------- + +export function buildErrorPage() { + renderView(errorView()); } \ No newline at end of file