You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
1.7 KiB
TypeScript

import { isoDateStr, dbg } from "../util";
type EntryKind =
| {
kind: "free";
text: string;
}
| {
kind: "listeningTo";
artist: string;
song: string;
url?: string;
}
| {
kind: "workingOn";
what: string;
url?: string;
};
type Entry = {
date: Date;
entries: EntryKind[];
};
const ENTRIES: Entry[] = [
{
date: new Date("2023-01-10"),
entries: [{ kind: "workingOn", what: "this site!" }],
},
{
date: new Date("2023-01-18"),
entries: [
{ kind: "free", text: "Looking for work!" },
{
kind: "listeningTo",
artist: "Saint Pepsi",
song: "Better",
url: "https://music.youtube.com/watch?v=WYvji5AXOfk",
},
],
},
{
date: new Date("2023-01-12"),
entries: [
{
kind: "listeningTo",
artist: "Darius (feat. Amaria)",
song: "FADED",
url: "https://music.youtube.com/watch?v=SfTOJ9PeQlY",
},
],
},
];
export const render = () => {
const entries = [...ENTRIES];
entries.sort((a, b) => +b.date - +a.date);
let out = '<div class="now">';
for (const entry of entries) {
out += `
<section>
<div class="date">
${isoDateStr(entry.date)}
</div>`;
for (const en of entry.entries) {
switch (en.kind) {
case "workingOn":
out += `<div class="working-on">Working on: ${en.what}</div>`;
break;
case "free":
out += `<div class="free">${en.text}</div>`;
break;
case "listeningTo":
out += `
<div class="listening-to">
Listening to:
<a href="${en.url}">
<span class="artist">${en.artist}</span>
-
<span class="song">${en.song}</span>
</a>
</div>
`;
break;
}
}
out += `</section>`;
}
out += "</div>";
return out;
};