forked from adobe-experience-league/exlm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path404.html
More file actions
128 lines (119 loc) · 3.96 KB
/
Copy path404.html
File metadata and controls
128 lines (119 loc) · 3.96 KB
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
<!doctype html>
<html>
<head>
<title>Page not found | Experience League | Adobe</title>
<script type="text/javascript">
window.isErrorPage = true;
window.errorCode = '404';
</script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:title" content="Page not found" />
<script src="/scripts/scripts.js" type="module" crossorigin="use-credentials"></script>
<script type="module">
import { sampleRUM } from '/scripts/lib-franklin.js';
import { getPathDetails } from '/scripts/scripts.js';
const { lang = 'en' } = getPathDetails() || {};
const errorPagePath = `/${lang}/404`;
const defaultErrorHTML = `
<div>
<p>Oops!</p>
<h1>The requested content was not found.</h1>
<p>Let us help you get back on the path.</p>
<h4>Most popular sections</h4>
<p><a href="/" title="Experience League homepage">Experience League homepage</a></p>
<p><a href="/${lang}/docs">Documentation</a></p>
<p><a href="/${lang}/playlists">Playlists</a></p>
<p><a href="//experienceleaguecommunities.adobe.com/">Community</a></p>
</div>
`;
const fetchAndParseHTML = async (tagName) => {
const container = document.querySelector('.section > div > div:first-child');
try {
const response = await fetch(errorPagePath);
if (!response.ok) throw new Error('Network response was not ok');
const text = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(text, 'text/html');
// Content authored in UE //
const contentElementUE = doc.querySelector(tagName);
if (contentElementUE) {
container.prepend(contentElementUE.querySelector('div'));
} else {
// Default Error Message if there's no authored text in UE //
container.insertAdjacentHTML('afterbegin', defaultErrorHTML);
}
} catch (error) {
// Default Error Message in case of any error //
container.insertAdjacentHTML('afterbegin', defaultErrorHTML);
}
};
window.addEventListener('load', () => {
sampleRUM('404', { source: document.referrer });
fetchAndParseHTML('main');
});
</script>
<link rel="stylesheet" href="/styles/styles.css" />
<style>
main.error .section {
display: flex;
flex-direction: column;
padding: 0 !important;
}
main.error .section > div {
margin: 0;
max-width: unset;
width: 100%;
}
main.error .section > div > div {
display: grid;
gap: 0.75rem;
grid-auto-rows: 1fr;
grid-auto-columns: 1fr;
grid-template-columns: 1fr;
}
main.error .section > div > div > div:first-child {
order: 2;
margin-left: 8.33333337%;
padding: 0.75rem;
}
main.error .section > div > div > div {
position: relative;
}
@media (min-width: 600px) {
main.error .section > div > div {
grid-template-columns: 1fr 1fr;
}
main.error .section > div > div > div:first-child {
order: -1;
}
}
main.error .error-image {
width: 100%;
height: 100%;
object-fit: cover;
position: absolute;
}
ul {
list-style: none !important;
}
ul li {
margin: 0;
margin-bottom: 0.5rem !important;
}
</style>
<link rel="stylesheet" href="/styles/lazy-styles.css" />
</head>
<body>
<header></header>
<main class="error">
<div class="section">
<div>
<div>
<img class="error-image" src="/404.webp" alt="404" />
</div>
</div>
</div>
</main>
<footer></footer>
</body>
</html>