-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
82 lines (58 loc) · 1.71 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>GEOLYTIX | MapIcons</title>
<link rel="icon" type="image/x-icon" href="https://geolytix.github.io/xyz/public/icons/favicon.ico" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
body {
padding: 20px;
}
.directory {
display: block;
}
.gallery {
display: flex;
flex-wrap: wrap;
margin-top: 20px;
}
.img {
width: 10vw;
height: 10vw;
margin: 10px;
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
</style>
</head>
<body>
</body>
<script type="module">
import {render, html} from 'https://unpkg.com/uhtml?module';
window.onload = async () => {
const pathname = window.location.pathname.replace(/\/MapIcons/, '');
const response = await fetch(`https://api.github.com/repos/geolytix/mapicons/contents${pathname}`)
const results = await response.json()
render(document.body, html`
<div>
${results.filter(el => el.type === 'dir').map(el => html`
<a
class="directory"
href="${`https://geolytix.github.io/MapIcons${pathname}${el.name}`}">${el.name}`)}
</div>
<div class="gallery">
${results.filter(el => el.name.match(/\.(gif|jpe?g|tiff?|png|webp|bmp|svg)$/i)).map(el => html`
<a
class="img"
href="${`https://geolytix.github.io/MapIcons${pathname}${el.name}`}"
style="${`background-image: url(https://geolytix.github.io/MapIcons${pathname}${el.name})`}">`)}`)
}
</script>
</html>