From 6f0c1549e9d577dc80b06be1c54084bce25353ce Mon Sep 17 00:00:00 2001 From: Charles Doucet Date: Thu, 20 Feb 2025 16:30:16 -0500 Subject: [PATCH] feat: basic error page 404 --- src/core/router.ts | 2 ++ src/views/error404.ts | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) 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