Add error pages and handling
This commit is contained in:
parent
aa94b17134
commit
0afc56d32e
27
layouts/error.vue
Normal file
27
layouts/error.vue
Normal file
@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<h1>{{ error.statusCode }}</h1>
|
||||
<p>{{ error.message }}</p>
|
||||
<p>
|
||||
<nuxt-link to="/">home</nuxt-link>
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
props: ['error'],
|
||||
components: {
|
||||
|
||||
},
|
||||
transition: {
|
||||
name: 'nanao',
|
||||
},
|
||||
middleware: 'shorten',
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
@ -4,9 +4,10 @@ import { tall } from 'tall';
|
||||
export default function (context) {
|
||||
return tall(process.env.SHORTENER_BASE+context.route.path).then(function(unshortenedUrl) {
|
||||
if(unshortenedUrl == process.env.SHORTENER_BASE) {
|
||||
return;
|
||||
}
|
||||
context.error({ statusCode: 404, message: "The page cannot be found"});
|
||||
} else {
|
||||
context.redirect(unshortenedUrl);
|
||||
}
|
||||
});
|
||||
// context.redirect("https://nanao.moe");
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
You are being redirected...
|
||||
<h1>404</h1>
|
||||
<p>oops!</p>
|
||||
<p>
|
||||
<nuxt-link to="/">home</nuxt-link>
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user