-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.vue
48 lines (41 loc) · 1011 Bytes
/
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
<template>
<div class="row">
<template v-if="error?.statusCode === 404">
<h1>404</h1>
<i18n-t keypath="error.path" tag="p" scope="global">
<template #path>
{{ $route.path }}
</template>
</i18n-t>
</template>
<template v-else>
<h1>An error occurred</h1>
<p v-if="error?.message" @click="toggleError()">{{ error.message }}</p>
<pre v-show="showError">{{ error }}</pre>
</template>
<NuxtLink :to="localePath({ name: 'index' })" class="button" @click="clearError()">Home page</NuxtLink>
</div>
</template>
<script setup lang="ts">
const localePath = useLocalePath()
type PageError = {
statusCode: number
message: string
}
defineProps<{
error?: PageError
}>()
const showError = ref(false)
function toggleError(value?: boolean) {
showError.value = value || !showError.value
}
useHead({
htmlAttrs: {
class: 'error404',
lang: 'en',
},
})
</script>
<style lang="scss">
@import 'assets/scss/error';
</style>