Repository navigation
Expand file tree
/
Copy path404.html
More file actions
79 lines (73 loc) · 2.2 KB
/
Copy path404.html
File metadata and controls
79 lines (73 loc) · 2.2 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Local First Tools — Not Found (checking redirects)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
:root { color-scheme: light dark; }
body {
font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
max-width: 42em;
margin: 3em auto;
padding: 0 1em;
}
h1 { font-size: 1.4em; margin-bottom: 0.3em; }
p { margin: 0.4em 0; }
code {
background: color-mix(in srgb, currentColor 8%, transparent);
padding: 0.1em 0.4em;
border-radius: 3px;
font-size: 0.9em;
}
a { color: #06c; text-decoration: none; }
a:hover { text-decoration: underline; }
#status { opacity: 0.7; font-size: 0.95em; }
</style>
</head>
<body>
<h1>Hmm, this page moved.</h1>
<p id="status">Checking the redirect map…</p>
<p>Or go to <a href="/localFirstTools/">the gallery</a> · <a href="/">home</a>.</p>
<script>
(async () => {
const status = document.getElementById("status");
// Deploy-prefix-aware: strip leading "/localFirstTools/" if present
const raw = location.pathname;
const stripped = raw.replace(/^\/localFirstTools\//, "").replace(/^\//, "");
// Try to find redirects.json — works whether served at / or /localFirstTools/
const candidates = [
"/localFirstTools/data/redirects.json",
"/data/redirects.json",
"data/redirects.json",
];
let map = null;
for (const url of candidates) {
try {
const res = await fetch(url);
if (res.ok) { map = await res.json(); break; }
} catch (_) {}
}
if (!map) {
status.textContent = "Couldn't load the redirect map. Try the gallery link below.";
return;
}
// Follow the chain up to 8 hops
let cur = stripped;
for (let i = 0; i < 8; i++) {
if (map[cur]) { cur = map[cur]; continue; }
break;
}
if (cur && cur !== stripped) {
// Preserve query + hash
const target = cur + location.search + location.hash;
status.innerHTML = 'Redirecting to <code>' + cur + '</code>…';
// Give the user a beat to see it
setTimeout(() => location.replace("/" + target.replace(/^\//, "")), 300);
return;
}
status.textContent = "No redirect found for this path.";
})();
</script>
</body>
</html>