-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
70 lines (65 loc) · 1.89 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
<!DOCTYPE html>
<html>
<head>
<title>fiug.dev welcome playground</title>
<meta charset="utf-8" />
<meta name="description" content="" />
<meta name="author" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="color-scheme" content="dark light" />
<link rel="stylesheet" href="index.css" />
</head>
<body></body>
<script type="module">
import getExamples from './index.examples.js';
const pages = await getExamples();
const { experiments, others, visit } = pages;
window.visit = visit;
const ListItem = ({ link, title, desc = '', preview }) => {
const element = document.createElement('div');
element.classList.add('card');
element.innerHTML = `
<a nohref onClick="visit('${title}', '${link}')">
<div class="preview" style="background-image:url('${preview}')"></div>
<div class="info">
<div class="title">${title.replace(/-/g, ' ')}</div>
<div class="description">${desc}</div>
</div>
</a>
`.trim();
return element;
};
const experimentsHeader = document.createElement('p');
experimentsHeader.textContent = 'experiments:';
document.body.append(experimentsHeader);
experiments.forEach((exp) => {
exp = Array.isArray(exp) ? exp : [exp, exp];
document.body.append(
ListItem({
link:
exp[0].endsWith('/') || exp[0].includes('#')
? `./${exp[0]}`
: `./${exp[0]}.html`,
title: exp[1],
desc: exp[2],
preview: exp[3]
})
);
});
const otherHeader = document.createElement('p');
otherHeader.textContent = 'other:';
document.body.append(otherHeader);
others.forEach((exp) => {
exp = Array.isArray(exp) ? exp : [exp, exp];
document.body.append(
ListItem({
link: exp[0],
title: exp[1],
desc: exp[2],
preview: exp[3]
})
);
});
</script>
</html>