-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy patherror.vue
More file actions
68 lines (61 loc) · 2.01 KB
/
error.vue
File metadata and controls
68 lines (61 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<script lang="ts" setup>
import BaseLayout from "@/layout/BaseLayout.vue";
import type { NuxtError } from "#app";
const props = defineProps<{ error: NuxtError }>();
useHead({
title: `${props.error.statusCode} - Forklore`,
meta: [
{ name: "description", content: "Page not found" },
{ name: "viewport", content: "width=device-width, initial-scale=1" },
],
});
const getErrorMessage = (statusCode: number) => {
const messages: Record<number, string> = {
404: "Page not found",
500: "Internal server error",
403: "Forbidden",
401: "Unauthorized",
};
return messages[statusCode] || "Something went wrong";
};
const getAsciiArt = (statusCode: number) => {
const art: Record<number, string> = {
404: ` _ _ ___ _ _
| || | / _ \\| || |
| || |_| | | | || |_
|__ _| |_| |__ _|
|_| \\___/ |_| `,
500: ` ____ ___ ___
| ___| / _ \\ / _ \\
|___ \\| | | | | | |
___) | |_| | |_| |
|____/ \\___/ \\___/ `,
403: " _ _ ___ _____ \n| || | / _ \\|___ / \n| || |_| | | | |_ \\ \n|__ _| |_| |___) |\n |_| \\___/|____/ ",
401: " _ _ ___ _ \n| || | / _ \\/ |\n| || |_| | | | |\n|__ _| |_| | |\n |_| \\___/|_|",
};
return art[statusCode] || statusCode.toString();
};
</script>
<template>
<BaseLayout>
<div class="flex items-center justify-center min-h-screen px-4 py-0">
<div class="flex flex-col items-center gap-6 max-w-2xl w-full">
<!-- ASCII art error code -->
<pre class="text-xl lg:text-2xl leading-tight text-center opacity-90">{{
getAsciiArt(error.statusCode!)
}}</pre>
<!-- Error message -->
<h1 class="text-2xl md:text-3xl font-medium text-center">
{{ getErrorMessage(error.statusCode!) }}
</h1>
<p
v-if="error.statusText"
class="text-base opacity-70 max-w-md text-center"
>
{{ error.statusText }}
</p>
<NuxtLink to="/" class="btn-solid"> <- Go back home </NuxtLink>
</div>
</div>
</BaseLayout>
</template>