-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.html
More file actions
55 lines (41 loc) · 1.11 KB
/
Copy pathtemplate.html
File metadata and controls
55 lines (41 loc) · 1.11 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MiniSite</title>
<style>
/*__CSS__{}*/
</style>
</head>
<body>
<main id="app" class="md-body"></main>
<script>const pages = __PAGES__;
const app = document.getElementById("app");
function normalizeRoute(route) {
route = route.trim();
// entfernt f�hrende /
route = route.replace(/^\/+/, "");
// fallback auf index
if (
route === "" ||
route === "/" ||
route === "index"
) {
return "index";
}
return route;
}
function render() {
let route = location.hash.slice(1);
route = normalizeRoute(route);
const html =
pages[route] ??
pages["404"] ??
`<h1>404</h1><p>This Page was not found!</p><p><a href="#">Back Home</a></p><p><a href="javascript:location.hash = '#/' + lastValid">Back to the last Page</a></p>`;
app.innerHTML = html;
}
window.addEventListener("hashchange", render);
window.addEventListener("DOMContentLoaded", render);</script>
</body>
</html>