Skip to content

Commit e6fa807

Browse files
afzal442ydcjeff
andauthored
feat: add 404 not found page (#178)
* adds 404 pagenotfound Signed-off-by: afzal442 <[email protected]> * modifies the file to show nav and footer Signed-off-by: afzal442 <[email protected]> * minor changes Signed-off-by: afzal442 <[email protected]> * refactors the description Signed-off-by: afzal442 <[email protected]> * minor changes fixed Signed-off-by: afzal442 <[email protected]> * minor typo fixed Signed-off-by: afzal442 <[email protected]> * Apply suggestions from code review Co-authored-by: Jeff Yang <[email protected]>
1 parent 2c6b423 commit e6fa807

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

src/main.js

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createRouter, createWebHistory } from 'vue-router'
44
import App from './App.vue'
55
import Home from './views/Home.vue'
66
import Create from './views/Create.vue'
7+
import PageNotFound from './views/PageNotFound.vue'
78

89
const routes = [
910
{
@@ -15,6 +16,12 @@ const routes = [
1516
name: 'create',
1617
path: '/create',
1718
component: Create
19+
},
20+
21+
{
22+
name: 'NotFound',
23+
path: '/:catchAll(.*)',
24+
component: PageNotFound
1825
}
1926
]
2027

src/views/PageNotFound.vue

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<template>
2+
<main>
3+
<NavBar />
4+
<div class="heading">
5+
<h1>404 Page Not Found</h1>
6+
<p>Oops! We couldn't find that page.</p>
7+
<p>
8+
Go back to the
9+
<RouterLink to="/" class="link alt" :style="learnMore"
10+
>homepage</RouterLink
11+
>.
12+
</p>
13+
</div>
14+
<Footer />
15+
</main>
16+
</template>
17+
18+
<script>
19+
import NavBar from '../components/NavBar.vue'
20+
import Footer from '../components/Footer.vue'
21+
import { onUnmounted } from 'vue'
22+
import { store } from '../store'
23+
24+
export default {
25+
components: {
26+
NavBar,
27+
Footer
28+
},
29+
setup() {
30+
onUnmounted(() => {
31+
// delete each property of config
32+
// since `store.config` is being watched in store.js
33+
// and Vue watch function does not tracked
34+
// if we reassign `store.config` (i.e. store.config = {})
35+
for (const config in store.config) {
36+
delete store.config[config]
37+
}
38+
// since we delete each property,
39+
// it is better to reassign the initial values
40+
// which are defined in store.js
41+
store.config.template = ''
42+
store.config.include_test = false
43+
store.config.output_dir = './logs'
44+
store.config.log_every_iters = 2
45+
})
46+
}
47+
}
48+
</script>
49+
50+
<style scoped>
51+
h1 {
52+
color: var(--c-brand-red);
53+
}
54+
.heading {
55+
max-width: 75vw;
56+
margin: auto;
57+
text-align: center;
58+
}
59+
.heading .alt {
60+
background: var(--c-white);
61+
color: var(--c-brand-red);
62+
}
63+
</style>

0 commit comments

Comments
 (0)