Browse Source

#11 Handle unknown paths with 404 page

trunk
Kevin Hoerr 10 months ago
parent
commit
051ff1871a
Signed by: kjhoerr GPG Key ID: 78E4BD33ACC22C86
3 changed files with 38 additions and 0 deletions
  1. +29
    -0
      public/static/404.html
  2. +4
    -0
      public/static/index.css
  3. +5
    -0
      src/routes.ts

+ 29
- 0
public/static/404.html View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<title>Page not found - AO Coverage</title>
<link rel="stylesheet" type="text/css" href="/static/index.css" />
</head>
<body>
<div id="top-half">
<div id="container">
<div id="logo"><img src="/favicon.ico" alt="logo" /></div>
<h1 id="tagline">404</h1>
</div>
</div>
<div id="bottom-half">
<div id="container">
<div id="smallcontent">
<p>Oops! The page you are looking for does not exist.</p>
<p><a href="/">Visit the front page</a></p>
</div>
</div>
</div>
</body>
</html>

+ 4
- 0
public/static/index.css View File

@ -39,6 +39,10 @@ div#content p {
padding: 0 10px;
}
div#smallcontent p {
text-align: center;
}
.code-container-container {
margin: 24px;
}


+ 5
- 0
src/routes.ts View File

@ -217,5 +217,10 @@ export default (metadata: Metadata): Router => {
retrieveFile(res, identity, "index.html");
});
router.use((_, res) => {
res.status(404);
res.sendFile(path.join(__dirname, "..", "public", "static", "404.html"));
});
return router;
};

Loading…
Cancel
Save