-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.vue
298 lines (278 loc) · 8.61 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<script setup lang="ts">
import VFlexibleLink from '@nypublicradio/nypr-design-system-vue3/v2/src/components/VFlexibleLink.vue'
defineProps({
error: {
type: Object,
default() { return {} },
},
})
const config = useRuntimeConfig()
const route = useRoute()
const { $htlbid, $analytics } = useNuxtApp()
const navigationState = useNavigation()
const navigationPromise = findNavigation().then(({ data }) => {
const navigationData = normalizeFindNavigationResponse(data)
navigationState.value = navigationData
return navigationData
})
const [navigation] = await Promise.all([
navigationPromise,
])
const atTop = ref(true)
const strapline = useStrapline()
const sensitiveContent = useSensitiveContent()
const fixedHeaderVisible = useFixedHeaderVisible()
const sidebarOpen = useSidebarIsOpen()
const sidebarOpenedFrom = useSidebarOpenedFrom()
function closeSidebar() {
sidebarOpen.value = false
}
let sidebarElements, firstElement, lastElement
function handleSidebarHidden() {
if (sidebarOpenedFrom.value?.focus)
sidebarOpenedFrom.value.focus()
}
function handleSidebarTab(e) {
if (!e.shiftKey && document.activeElement === lastElement) {
firstElement.focus()
e.preventDefault()
}
}
function handleSidebarShiftTab(e) {
if (document.activeElement === firstElement) {
lastElement.focus()
e.preventDefault()
}
}
function handleSidebarShown() {
sidebarElements = Array.from(
document.querySelectorAll(
'.p-sidebar a:not([disabled]), .p-sidebar button:not([disabled])',
),
).filter(element => element.clientWidth + element.clientHeight !== 0)
firstElement = sidebarElements[0]
lastElement = sidebarElements[sidebarElements.length - 1]
}
function trackSidebarClick(label) {
// emitted mobile menu click event
$analytics.scheduleEvent('click_tracking', {
event_category: 'Click Tracking - Mobile Menu',
component: 'header',
event_label: label,
})
closeSidebar()
}
onBeforeMount(() => {
const currentSteamStation = useCurrentSteamStation()
updateLiveStream(currentSteamStation.value)
})
onMounted(() => {
$analytics.schedulePageView({ page_type: 'error_page' })
document.addEventListener('scroll', () => {
atTop.value = !(window.scrollY > 0)
// atBottom.value = ((window.scrollY + (window.innerHeight + 115) >= document.body.scrollHeight)) ? true : false
})
$htlbid.init()
$htlbid.setTargeting({
is_testing: config.public.HTL_IS_TESTING,
})
$htlbid.setTargetingForRoute(route)
})
watch(route, (value) => {
$htlbid.setTargetingForRoute(value)
$htlbid.clearAds()
})
function newsletterSubmitEvent() {
$analytics.scheduleEvent('click_tracking', {
event_category: 'Click Tracking - Footer - Newsletter',
component: 'footer',
event_label: 'Newsletter',
})
}
useHead({
htmlAttrs: {
lang: 'en',
},
title: 'Gothamist: New York City Local News, Food, Arts & Events',
})
useServerHead({
link: [
{ rel: 'preconnect', href: config.public.API_URL, crossorigin: '', tagPriority: 'high' },
{ rel: 'preconnect', href: config.public.IMAGE_CDN_URL, tagPriority: 'high' },
],
meta: [
{ name: 'description', content: 'Gothamist is a website about New York City news, arts and events, and food, brought to you by New York Public Radio.' },
{ property: 'og:site_name', content: 'Gothamist' },
{ property: 'og:type', content: 'website' },
{ property: 'og:url', content: `https://www.gothamist.com${route.fullPath}` },
{ property: 'og:title', content: 'Gothamist: New York City Local News, Food, Arts & Events' },
{ property: 'og:site_name', content: 'Gothamist' },
{ property: 'og:description', content: 'Gothamist is a non-profit local newsroom, powered by WNYC.' },
{ property: 'og:image', content: config.public.OG_IMAGE },
{ property: 'og:locale', content: 'en_US' },
{ property: 'og:image:width', content: '1200' },
{ property: 'og:image:height', content: '650' },
{ property: 'fb:app_id', content: '151261804904925' },
{ name: 'twitter:card', content: 'summary_large_image' },
{ name: 'twitter:site', content: '@gothamist' },
],
})
</script>
<template>
<div class="error-page">
<div v-if="!sensitiveContent" class="htlad-skin" />
<div
class="leaderboard-ad-wrapper flex justify-content-center align-items-center"
>
<div v-if="!sensitiveContent" class="htlad-index_leaderboard_1" />
<div class="leaderboard-container">
<Transition name="fixed-header">
<GothamistMainHeader
v-if="fixedHeaderVisible && route.name !== 'sectionSlug-articleSlug'"
class="fixed-header"
:navigation="navigation"
:is-minimized="true"
:donate-url-base="config.public.donateUrlBase"
utm-campaign="homepage-header"
/>
</Transition>
</div>
</div>
<GothamistMainHeader
:navigation="navigation"
:is-minimized="route.name !== 'index'"
:donate-url-base="config.public.donateUrlBase"
utm-campaign="goth_header"
@visible="() => { fixedHeaderVisible = false }"
@not-visible="() => { fixedHeaderVisible = true }"
/>
<Sidebar
v-model:visible="sidebarOpen"
:base-z-index="6000"
position="right"
data-style-mode="dark"
aria-close-label="close the navigation menu"
class="gothamist-sidebar px-3 md:px-4"
@show="handleSidebarShown"
@hide="handleSidebarHidden"
@keydown.esc="closeSidebar"
@keydown.tab="handleSidebarTab"
@keydown.shift.tab="handleSidebarShiftTab"
>
<template #header>
<div class="gothamist-sidebar-header flex md:hidden">
<VFlexibleLink
to="/"
raw
@click="trackSidebarClick('sidebar logo')"
>
<LogoGothamist class="gothamist-sidebar-header-logo pr-2" />
</VFlexibleLink>
<div class="gothamist-sidebar-header-tagline" v-html="strapline" />
</div>
</template>
<template #default>
<GothamistSidebarContents
:navigation="navigation"
:donate-url-base="config.public.donateUrlBase"
utm-campaign="goth_hamburger"
class="mt-3"
@menu-list-click="trackSidebarClick($event)"
/>
</template>
</Sidebar>
<main>
<section class="error-page-header">
<div class="content">
<div class="error-page-error pt-2">
{{ error.statusCode }} Error - {{ error.statusMessage }}
</div>
<div v-if="config.public.DEBUG === 'true'" class="mt-4">
<pre class="font-bold">{{ error.message }}</pre>
<div v-html="error.description" />
</div>
<h2 class="text-center p-6">
The page you're looking for doesn't appear to exist. Please check
out our latest stories below.
</h2>
</div>
</section>
<section>
<div class="content">
<!-- featured area -->
<article-recirculation tracking-component-location="Error Page Recirculation Module" />
<!-- newsletter -->
<div class="mt-8 mb-5">
<hr class="black mb-4">
<newsletter-home @submit="newsletterSubmitEvent" />
</div>
</div>
</section>
</main>
<gothamist-footer :navigation="navigation" />
</div>
</template>
<style lang="scss">
.error-page {
@include page-top-gradient;
.error-page-header {
background: var(--soybean200);
}
.error-page-error {
font-size: var(--font-size-5);
line-height: var(--font-size-5);
font-weight: 400;
text-transform: uppercase;
text-align: left;
border-top: solid 1px var(--black);
font-family: var(--font-family-header);
@include media('>lg') {
font-size: var(--font-size-6);
line-height: var(--font-size-6);
}
}
}
.gothamist-sidebar {
background-color: var(--black-500);
width: 100vw !important;
@include media('>sm') {
width: 480px !important;
}
.p-sidebar-close {
color: white !important;
&:hover {
color: initial !important;
}
}
}
.gothamist-sidebar .p-sidebar-header {
justify-content: space-between;
padding: 1rem 0 0 0;
}
.gothamist-sidebar .p-sidebar-header {
align-items: flex-start;
}
.gothamist-sidebar-header-logo {
width: 120px;
height: auto;
* {
fill: white;
}
}
.gothamist-sidebar .p-sidebar-content {
padding: 0;
}
.gothamist-sidebar-header-tagline {
max-width: 160px;
font-family: var(--font-family-header);
font-size: 12px;
line-height: var(--font-size-5);
color: white;
align-self: flex-end;
padding-right: 1rem;
@include media('<375px') {
font-size: 10px;
line-height: var(--font-size-4);
}
}
</style>