-
Notifications
You must be signed in to change notification settings - Fork 22
/
index.html
94 lines (83 loc) · 2.44 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
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
html {
color: #333;
line-height: 1.4;
}
body {
max-width: 100ch;
margin: 1rem auto;
padding: 0 1rem;
}
h1, h2, h3, h4, h5, h6 {
font-family: sans-serif;
}
.author-list {
list-style-type: none;
padding: 0;
}
.author {
margin: 1rem 0 2rem;
}
.author img {
width: 60px;
height: 60px;
border-radius: 3px;
background-color: #f0f0f0;
float: right;
margin: 0 0 1rem 1rem;
}
.talk-list {
padding-left: 2rem;
}
</style>
</head>
<body>
<h1>Talks by author</h1>
<p>This page views <a href="https://github.com/dctech/speaking/issues?labels=talk" target="_blank">talks</a> submitted to <a href="https://github.com/dctech/speaking" target="_blank">github.com/dctech/speaking</a>, grouped by author.</p>
<ul class="author-list">
<li>Loading…</li>
</ul>
<script>
(async () => {
const issuesByAuthor = (authors, issue) => {
authors[issue.user.login] = authors[issue.user.login] || {
user: issue.user,
issues: [],
};
authors[issue.user.login].issues.push(issue);
return authors;
};
const response = await fetch('https://api.github.com/repos/dctech/speaking/issues?labels=talk');
const issues = await response.json();
const authors = Object.values(issues.reduce(issuesByAuthor, {}));
authors.sort((a, b) => a.user.login.toLowerCase() < b.user.login.toLowerCase() ? -1 : 1);
document.querySelector('ul').innerHTML = authors.map(({user, issues}) => {
const talks = issues.map((talk) => {
return `
<li class="talk">
<a href="${talk.html_url}" target="_blank">
${talk.title}
</a>
</li>
`.trim();
}).join('');
return `
<li class="author">
<a href="${user.html_url}" target="_blank">
<img src="${user.avatar_url}" alt="Avatar of ${user.login}">
<h2>${user.login}</h2>
</a>
<ul class="talk-list">
${talks}
</ul>
</li>
`.trim();
}).join('');
})();
</script>
</body>
</html>