Add error pages and handling

This commit is contained in:
Damillora 2019-09-28 18:00:59 +07:00
parent aa94b17134
commit 0afc56d32e
3 changed files with 35 additions and 3 deletions

27
layouts/error.vue Normal file
View 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>

View File

@ -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(unshortenedUrl);
});
// context.redirect("https://nanao.moe");
}

View File

@ -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>