-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease_notes.js
46 lines (41 loc) · 1.48 KB
/
release_notes.js
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
(function() {
const notesPromise = (async function() {
const uri = location.protocol === 'file:' ? 'https://www.sauce.llc/' : '/';
return await fetch(uri + 'release_notes.json').then(x => x.json());
})();
function notesToHTML(notes) {
const html = [];
for (const x of notes) {
if (typeof x === 'string') {
html.push(`<li>${x}</li>`);
} else {
html.push(`<li>${x.html}</li>`);
if (x.children && x.children.length) {
html.push(`<ul>${notesToHTML(x.children)}</ul>`);
}
}
}
return html.join('');
}
async function onDOMLoaded() {
const notes = await notesPromise;
const frag = document.createDocumentFragment();
for (const x of notes.reverse()) {
if (x.private) {
continue;
}
const release = document.createElement('release');
release.id = x.version;
release.innerHTML = `
<header>
<div class="version">v${x.version}</div>
<div class="date">${new Date(x.ts).toLocaleDateString()}</div>
</header>
<ul class="notes">${notesToHTML(x.notes)}</ul>
`;
frag.appendChild(release);
}
document.querySelector('section.notes').appendChild(frag);
}
addEventListener('DOMContentLoaded', onDOMLoaded);
})();