Skip to content

feat: add 404 not found page #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createRouter, createWebHistory } from 'vue-router'
import App from './App.vue'
import Home from './views/Home.vue'
import Create from './views/Create.vue'
import PageNotFound from './views/PageNotFound.vue'

const routes = [
{
Expand All @@ -15,6 +16,12 @@ const routes = [
name: 'create',
path: '/create',
component: Create
},

{
name: 'NotFound',
path: '/:catchAll(.*)',
component: PageNotFound
}
]

Expand Down
63 changes: 63 additions & 0 deletions src/views/PageNotFound.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<template>
<main>
<NavBar />
<div class="heading">
<h1>404 Page Not Found</h1>
<p>Oops! We couldn't find that page.</p>
<p>
Go back to the
<RouterLink to="/" class="link alt" :style="learnMore"
>homepage</RouterLink
>.
</p>
</div>
<Footer />
</main>
</template>

<script>
import NavBar from '../components/NavBar.vue'
import Footer from '../components/Footer.vue'
import { onUnmounted } from 'vue'
import { store } from '../store'

export default {
components: {
NavBar,
Footer
},
setup() {
onUnmounted(() => {
// delete each property of config
// since `store.config` is being watched in store.js
// and Vue watch function does not tracked
// if we reassign `store.config` (i.e. store.config = {})
for (const config in store.config) {
delete store.config[config]
}
// since we delete each property,
// it is better to reassign the initial values
// which are defined in store.js
store.config.template = ''
store.config.include_test = false
store.config.output_dir = './logs'
store.config.log_every_iters = 2
})
}
}
</script>

<style scoped>
h1 {
color: var(--c-brand-red);
}
.heading {
max-width: 75vw;
margin: auto;
text-align: center;
}
.heading .alt {
background: var(--c-white);
color: var(--c-brand-red);
}
</style>