Skip to content

Commit 5c1ea49

Browse files
add 404 page
1 parent b2482ee commit 5c1ea49

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-0
lines changed

app/router.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ AppRouter.map(function () {
8989
this.route('module', { path: '/modules/:module' });
9090
this.route('data-class', { path: '/data/classes/:class' });
9191
this.route('data-module', { path: '/data/modules/:module' });
92+
this.route('not-found', { path: '/*' });
9293
});
9394

9495
/*

app/routes/not-found.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Route from '@ember/routing/route';
2+
import { inject as service } from '@ember/service';
3+
4+
export default class NotFoundRoute extends Route {
5+
@service fastboot;
6+
7+
beforeModel() {
8+
if (!this.fastboot.isFastBoot) {
9+
return;
10+
}
11+
12+
this.fastboot.response.statusCode = 404;
13+
}
14+
}

app/styles/app.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ a.class-field-description--link:hover svg {
109109
fill: var(--color-brand);
110110
}
111111

112+
.whoops {
113+
display: flex;
114+
flex-direction: column;
115+
justify-content: center;
116+
align-items: center;
117+
}
118+
119+
.whoops img {
120+
width: 40%;
121+
margin: var(--spacing-2);
122+
}
123+
112124
@media (min-width: 845px) {
113125
.es-header {
114126
padding: 0 var(--spacing-4);
@@ -124,3 +136,14 @@ a.class-field-description--link:hover svg {
124136
margin-top: var(--spacing-4);
125137
}
126138
}
139+
140+
@media (max-width: 450px) {
141+
.whoops img {
142+
width: 80%;
143+
margin: var(--spacing-4);
144+
}
145+
146+
.whoops__message {
147+
margin: var(--spacing-4);
148+
}
149+
}

app/templates/not-found.hbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<article class="whoops">
2+
<img src="/assets/images/stinky-fish.png" alt="tomster stinky fish"/>
3+
<h2 class="whoops__title">Ack! 404 friend, you're in the wrong place</h2>
4+
<div class="whoops__message">
5+
<span>
6+
<LinkTo @route='index'>Click here to go home</LinkTo>
7+
</span>
8+
</div>
9+
</article>

public/assets/images/stinky-fish.png

70.8 KB
Loading

tests/unit/routes/not-found-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { module, test } from 'qunit';
2+
import { setupTest } from 'ember-qunit';
3+
4+
module('Unit | Route | not-found', function (hooks) {
5+
setupTest(hooks);
6+
7+
test('it exists', function (assert) {
8+
let route = this.owner.lookup('route:not-found');
9+
assert.ok(route);
10+
});
11+
});

0 commit comments

Comments
 (0)