-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patherror.vue
93 lines (90 loc) · 2.24 KB
/
error.vue
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<template>
<div class="flex items-center justify-center h-screen">
<!-- <VitePwaManifest /> -->
<NuxtLoadingIndicator />
<v-card id="message" max-width="360" class="text-left">
<v-card-subtitle class="text--primary pb-0">
<h2
class="font-weight-bold text-subtitle-1"
style="letter-spacing: 3px"
>
{{ error.statusCode }}
</h2>
</v-card-subtitle>
<v-card-title class="pt-0">
<h1 class="text-h5 font-weight-light" style="letter-spacing: 3px">
{{ title }}
</h1>
</v-card-title>
<v-card-text
v-if="error.statusMessage !== error.message || error.statusCode === 404"
class="text--primary font-weight-light"
style="line-height: 140%; letter-spacing: 1px"
>
{{ description }}
</v-card-text>
<v-card-text>
<v-row v-if="error.statusCode !== 404" no-gutters>
<v-col>
<v-btn color="primary" block size="x-large" @click="clearError()"
>Try again</v-btn
>
</v-col>
</v-row>
<v-row>
<v-col>
<v-btn
color="primary"
block
size="x-large"
@click="clearError({ redirect: '/' })"
>
Home
</v-btn>
</v-col>
</v-row>
</v-card-text>
</v-card>
</div>
</template>
<script setup lang="ts">
const props = defineProps({
error: {
type: Object,
default: () => {},
},
});
const i18nHead = useLocaleHead({
addDirAttribute: true,
identifierAttribute: 'id',
addSeoAttributes: true,
});
const { t } = useI18n({
useScope: 'local',
});
const title =
props.error.statusCode === 404
? t('error.404.heading')
: props.error.statusMessage;
const description =
props.error.statusCode === 404
? t('error.404.description')
: props.error.statusMessage !== props.error.message
? props.error.message
: undefined;
useHead({
title,
htmlAttrs: {
lang: i18nHead.value.htmlAttrs!.lang,
},
link: [...(i18nHead.value.link ?? [])],
meta: [
...(i18nHead.value.meta ?? []),
{
hid: 'description',
name: 'description',
content: description,
},
],
});
</script>