Skip to content

Commit

Permalink
Merge pull request #3 from ninelabs/404-page
Browse files Browse the repository at this point in the history
Handle missing pages
  • Loading branch information
orderedlist committed Dec 20, 2016
2 parents cf280be + 210b628 commit 1674902
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion index.js
Expand Up @@ -46,7 +46,17 @@ app.get('/components', function (req, res) {
});

app.get('/prototype/:page', function(req, res) {
res.render('prototype/' + req.params.page, {layout: 'prototype'});
res.render('prototype/' + req.params.page, {layout: 'prototype'}, function(err, html) {
if (err) {
res.status(404).render('404');
} else {
res.send(html);
}
});
});

app.get('*', function(req, res) {
res.status(404).render('404');
});

app.listen(process.env.PORT || 3000, function () {
Expand Down
10 changes: 10 additions & 0 deletions views/404.handlebars
@@ -0,0 +1,10 @@
<div class="row flex-items-xs-center konstru-full-window m-0">
<div class="text-xs-center flex-xs-middle">
<div class="display-4 text-muted">
404 not found
</div>
<p>
<a href="/">Go back to the Home Page</a>
</p>
</div>
</div>
2 changes: 1 addition & 1 deletion views/partials/nav.handlebars
@@ -1,5 +1,5 @@
<nav class="navbar navbar-dark bg-inverse">
<a href="prototype/dashboard" class="navbar-brand">
<a href="/" class="navbar-brand">
<img src="/images/konstru.svg" alt="Konstru">
</a>
<nav class="nav navbar-nav float-xs-left">
Expand Down

0 comments on commit 1674902

Please sign in to comment.