Skip to content

Commit e2cb884

Browse files
committed
Fetch track thumbnails remotely
1 parent 42501f0 commit e2cb884

32 files changed

+5071
-148
lines changed

src/components/Nav.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ import Logo from "../content/TH.svg";
33
import Icon from "./Icon.astro";
44
import Button from "./Button.astro";
55
6-
const routes = ["blog", "tracks"];
6+
const routes = ["blog", "tracks", "services"];
77
---
88

99
<nav class="sticky top-0 z-10 max-w-none bg-white dark:bg-neutral-800">
1010
<div
11-
class="mx-auto flex max-w-screen-xl items-center justify-between ps-4 pe-2 text-neutral-700 dark:text-neutral-300"
11+
class="mx-auto flex max-w-screen-xl items-center justify-between gap-4 ps-4 pe-2 text-neutral-700 dark:text-neutral-300"
1212
>
1313
<a href="/" title="Home">
1414
<Logo width={42} height={42} />
1515
</a>
16-
<div class="flex">
16+
<div class="flex overflow-x-auto">
1717
{
1818
routes.map((route) => (
1919
<Button href={`/${route}`}>

src/components/TableOfContents.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const { headings } = Astro.props;
1111

1212
<details
1313
id="toc"
14-
class="sticky top-10 z-10 -translate-y-px border border-neutral-300 bg-white lg:top-2 dark:border-neutral-600 dark:bg-neutral-800"
14+
class="sticky top-10 z-10 -translate-y-px border border-neutral-300 bg-white xl:top-2 dark:border-neutral-600 dark:bg-neutral-800"
1515
>
1616
<summary
1717
title="Table of contents"

src/components/Track.astro

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,46 @@
11
---
2-
import { Image } from "astro:assets";
3-
42
interface Props {
53
title: string;
64
artist: string;
75
album: string;
86
youtubeLink: string;
9-
cover: any;
7+
index: number;
108
}
119
12-
const { title, artist, album, youtubeLink, cover } = Astro.props;
10+
const { title, artist, album, youtubeLink, index } = Astro.props;
11+
12+
const uniqueArtists = [...new Set(artist.split(",").map((a) => a.trim()))].join(
13+
", ",
14+
);
15+
16+
const videoId = youtubeLink.split("v=")[1];
17+
const thumbnail = `https://img.youtube.com/vi/${videoId}/maxresdefault.jpg`;
1318
---
1419

15-
<figure>
20+
<figure
21+
class="relative flex flex-col border border-neutral-400 duration-300 hover:scale-105 active:scale-105 dark:border-neutral-500"
22+
>
23+
<span
24+
class="absolute -start-2 -top-2 border border-neutral-400 bg-white px-2 text-lg font-bold dark:border-neutral-500 dark:bg-neutral-800"
25+
>{index}</span
26+
>
1627
<a href={youtubeLink}>
17-
<Image
18-
src={cover}
28+
<img
29+
src={thumbnail}
1930
alt={`Cover for the song '${title}' by artist(s) '${artist}'`}
20-
class="border border-neutral-400 duration-300 hover:scale-105 active:scale-105 dark:border-neutral-500"
31+
class="aspect-video w-full border-b border-neutral-400 dark:border-neutral-500"
2132
/>
2233
</a>
23-
<figcaption class="flex flex-col p-4 text-center">
34+
<figcaption
35+
class="flex flex-1 flex-col p-6 text-center"
36+
style="word-break: break-word;"
37+
>
2438
<p class="text-lg font-bold">{title}</p>
25-
<p>{artist}</p>
26-
<p class="text-sm">{album}</p>
39+
<p class="mb-3">{uniqueArtists}</p>
40+
<p
41+
class="mt-auto border-t border-neutral-400 pt-3 text-sm dark:border-neutral-500"
42+
>
43+
{album}
44+
</p>
2745
</figcaption>
2846
</figure>

src/content.config.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ const blog = defineCollection({
1313

1414
const tracks = defineCollection({
1515
loader: file("./src/content/tracks.json"),
16-
schema: ({ image }) =>
17-
z.object({
18-
id: z.number().positive(),
19-
title: z.string(),
20-
youtubeLink: z.string().url(),
21-
artist: z.string(),
22-
album: z.string(),
23-
cover: image(),
24-
}),
16+
schema: z.object({
17+
id: z.number().positive(),
18+
title: z.string(),
19+
youtubeLink: z.string().url(),
20+
artist: z.string(),
21+
album: z.string(),
22+
}),
2523
});
2624

2725
export const collections = { blog, tracks };
-67.6 KB
Binary file not shown.
-39.3 KB
Binary file not shown.
-40.9 KB
Binary file not shown.
-25.5 KB
Binary file not shown.
-13.8 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)