generated from acdh-oeaw/template-app-nuxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.vue
60 lines (53 loc) · 1.37 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
<script lang="ts" setup>
const props = defineProps<{
error:
| Error
| {
url: string;
statusCode: number;
statusMessage: string;
message: string;
description: string;
};
}>();
// const locale = useLocale();
const t = useTranslations();
const localePath = useLocalePath();
const isNotFoundPage = computed(() => {
return "statusCode" in props.error && props.error.statusCode === 404;
});
/** `error.vue` is *not* wrapped in default layout out of the box. */
useHead({
titleTemplate: computed(() => {
return ["%s", t("Metadata.title")].join(" | ");
}),
title: computed(() => {
return isNotFoundPage.value ? t("NotFoundPage.meta.title") : t("ErrorPage.meta.title");
}),
});
useSeoMeta({
robots: {
noindex: true,
},
});
function onReset() {
void clearError({ redirect: localePath("/") });
}
</script>
<template>
<MainContent class="grid min-h-full place-content-center place-items-center gap-y-3">
<template v-if="isNotFoundPage">
<h1>{{ t("NotFoundPage.title") }}</h1>
</template>
<template v-else>
<h1>{{ t("ErrorPage.title") }}</h1>
<div class="flex items-center gap-4">
<span>{{ "statusCode" in props.error ? props.error.statusCode : 500 }}</span>
<span>{{ props.error.message }}</span>
</div>
<div>
<button @click="onReset">{{ t("ErrorPage.try-again") }}</button>
</div>
</template>
</MainContent>
</template>