forked from Qiskit/qiskit.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.vue
127 lines (106 loc) · 2.98 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<template>
<div>
<qiskit-ui-shell variant="hide-account" @on-click="onClick" />
<div class="error-page">
<div class="cds--grid">
<div class="cds--row">
<div class="cds--col-lg-4">
<h1 class="error-page__title">{{ error.statusCode }}</h1>
<p>{{ error.message }}</p>
<p class="error-page__message">
<!-- eslint-disable-next-line vue/no-v-html -->
Or as we like to say, <span v-html="randomMessage" />
</p>
<UiCta
:label="backToCta.label"
:segment="backToCta.segment"
:url="backToCta.url"
/>
</div>
<div class="cds--col-lg-8">
<img
class="error-page__img"
:src="errorImgSrc"
alt="Playful illustration of a cat in a cardboard box"
/>
</div>
</div>
</div>
</div>
<LayoutFooter />
</div>
</template>
<script setup lang="ts">
import { NuxtError } from "#app";
import { TextLink } from "~/types/links";
interface Props {
error: NuxtError;
}
const route = useRoute();
const props = defineProps<Props>();
const pageTitle = computed<string>(() => {
return props.error.statusMessage ?? "Error";
});
useHead({
title: pageTitle,
});
const backToHomeCta: TextLink = {
url: "/",
label: "Back to Qiskit home page",
segment: {
cta: "back-to-home",
location: "error-page",
},
};
const backToDocsCta: TextLink = {
url: "/documentation",
label: "Back to Qiskit documentation",
segment: {
cta: "back-to-documentation",
location: "error-page",
},
};
const backToCta = route.path.startsWith("/documentation/")
? backToDocsCta
: backToHomeCta;
const errorImgSrc = `/images/error-page/cat${getRandomInt(1, 9)}.png`;
function getRandomInt(min: number, max: number) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
const messages = [
"this isn’t exactly a <em><strong>superposition</strong></em> to be in.",
"looks like something here is an <em><strong>entangled</strong></em> mess.",
"we apologize for the <em><strong>interference</strong></em> you’re seeing on this page.",
"you’ve reached the edge of the multi-verse.",
"this page loads fine another dimension, but not this dimension.",
];
const randomMessage = computed<string>(() => {
const randomIndex = Math.floor(Math.random() * messages.length);
return messages[randomIndex];
});
const { trackClickEvent } = useSegment();
function onClick(e: CustomEvent) {
trackClickEvent(`${e.detail?.label?.toLowerCase()}`, "menu");
}
</script>
<style lang="scss" scoped>
@use "~/assets/scss/carbon.scss";
.error-page {
padding: carbon.$spacing-10 0;
&__title {
margin-bottom: carbon.$spacing-05;
}
&__message {
margin-bottom: carbon.$spacing-06;
}
&__img {
display: block;
max-width: 100%;
}
}
qiskit-ui-shell {
--header-content-max-width: 96rem;
}
</style>