Skip to content

Commit 680bdcc

Browse files
committed
Add custom error page
1 parent 5c3ec85 commit 680bdcc

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

error.vue

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<script lang="ts" setup>
2+
import type { NuxtError } from 'nuxt/app'
3+
4+
defineProps({
5+
error: Object as () => NuxtError,
6+
})
7+
8+
const { public: { appName } } = useConfig()
9+
10+
useHead({
11+
titleTemplate: () => `Error Page | ${appName}`,
12+
})
13+
14+
const handle = () => {
15+
clearError({
16+
redirect: '/',
17+
})
18+
}
19+
</script>
20+
21+
<template>
22+
<AppLayout name="minimal">
23+
<div class="flex flex-col items-center gap-8">
24+
<template v-if="error">
25+
<template v-if="error?.statusCode === 404">
26+
<h1 class="font-bold text-2xl text-center">404</h1>
27+
<p v-if="error">
28+
{{ error.message }}
29+
</p>
30+
</template>
31+
<template v-else>
32+
<h1 class="font-bold text-2xl text-center">Unknown error</h1>
33+
</template>
34+
</template>
35+
<CoreButton class="border border-layer" @click="handle">Home</CoreButton>
36+
</div>
37+
</AppLayout>
38+
</template>

0 commit comments

Comments
 (0)