website/music/index.md

33 lines
1.2 KiB
Markdown
Raw Normal View History

2024-09-05 19:36:09 -05:00
# Music
2024-09-06 01:33:57 -05:00
<script id="albums">
const thisScript = document.getElementById("albums");
fetch("/music/albums.json")
.then((response) => response.json())
.then((json) => {
2024-09-06 20:19:54 -05:00
console.log(json);
2024-09-06 01:33:57 -05:00
let html = "";
2024-09-06 20:19:54 -05:00
for (const category in json) {
let albums = json[category];
html = html.concat(`<h2>${category}</h2><section>`);
for (let i = 0; i < albums.length; i++) {
let album = albums[i];
let link = "/res/albums/" + album.link + ".webp";
let name = album.name;
let artist = album.artist;
let template = `<figure>
<img src="${link}">
<figcaption>
<b>${name}</b><br/><em>${artist}</em>
</figcaption>
</figure>`;
html = html.concat(template);
}
html = html.concat("</section>")
2024-09-06 01:33:57 -05:00
}
2024-09-06 20:19:54 -05:00
let section = document.createElement("div");
2024-09-06 01:33:57 -05:00
section.innerHTML = html;
thisScript.replaceWith(section); // lol
});
</script>