-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
84 lines (77 loc) · 3.02 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
83
84
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-theme-deep-orange.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Micronaut</title>
<script>
fetch('all-codelabs.json')
.then(res => res.json())
.then(codelabs => {
createCards(codelabs);
})
.catch(err => console.log("error: ", err));
function codelabTemplate({ title, summary, presentationLink, codelabLink, demoLink, createdDate, author,
containsPresentation, containsDemo }) {
return `<div class="w3-card-4">
<header class="w3-container w3-theme" style="height: 50px;overflow: hidden;">
<h3>${title}</h3>
</header>
<div class="w3-container w3-text-theme w3-center" style="height:300px;overflow-x:auto;">
<p style="height:200px;overflow-x:auto;">
${summary}
</p>
<div class="w3-section" style="height:50px;">
${containsPresentation ? `<a href=${presentationLink} class="w3-button w3-indigo">presentation</a>` : ''}
<a href=${codelabLink} class="w3-button w3-theme">codelab</a>
${containsDemo ? `<a href=${demoLink} class="w3-button w3-grey">demo</a>` : ''}
</div>
</div>
<footer class="w3-bar w3-theme" style="padding: 0 15px;">
<span>${createdDate}</span>
<span style="float:right">${author? author : ""}</span>
</footer>
</div>`;
}
function addCodelab(codelab) {
const container = document.querySelector("#codelabs");
const div = document.createElement('div');
div.style.width = "30%";
div.style.margin = "5px 20px";
div.innerHTML = codelabTemplate({
title: codelab.title,
summary: codelab.summary,
containsPresentation: codelab.containsPresentation,
presentationLink: 'presentations/' + codelab.id + '/index.html',
codelabLink: `codelabs/${codelab.id}/index.html`,
containsDemo: codelab.containsDemo,
demoLink: 'demo/' + codelab.id,
createdDate: new Date(codelab.updated).toLocaleDateString(),
author: codelab.author,
})
// const codelabNode = createCodelab(codelab);
container.appendChild(div);
}
function createCards(codelabs) {
codelabs.forEach(codelab => {
addCodelab(codelab);
});
}
</script>
<style>
#codelabs {
display: flex;
flex-wrap: wrap;
}
</style>
</head>
<body>
<h1 style="text-align: center;" class="w3-text-theme"> Micronaut tutorials </h1>
<div id="codelabs">
</div>
</body>
</html>