Skip to content

Commit 40abc8d

Browse files
authored
feat: [#6] basic error page 404
1 parent 8307651 commit 40abc8d

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/core/router.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { EVENT_BUS } from "./";
2+
import {buildErrorPage} from "../views/error404.ts";
23

34
type RouteHandler = (params?: Record<string, string>) => void;
45

@@ -27,6 +28,7 @@ class Router {
2728
return;
2829
}
2930
}
31+
buildErrorPage();
3032
console.error(`No handler found for path: ${path}`);
3133
}
3234

src/views/error404.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-

2-
export function buildErrorPage() {
1+
import {writeTitle} from "./utils";
2+
import {renderView} from "./index.ts";
3+
4+
5+
function errorView() {
6+
const article = document.createElement('article');
7+
const viewTitle = writeTitle("h1", "Page not found 404");
38

9+
article.appendChild(viewTitle);
10+
return article;
11+
}
12+
13+
//-----------------------------------------------------------------------
14+
15+
export function buildErrorPage() {
16+
renderView(errorView());
417
}

0 commit comments

Comments
 (0)