tangled
alpha
login
or
join now
vielle.dev
/
site
0
fork
atom
Personal Site
0
fork
atom
overview
issues
pulls
pipelines
Show now playing song
vielle.dev
7 months ago
f3cc7307
100406e1
verified
This commit was signed with the committer's
known signature
.
vielle.dev
SSH Key Fingerprint:
SHA256:/4bvxqoEh9iMdjAPgcgAgXKZZQTROL3ULiPt6nH9RSs=
+27
-1
1 changed file
expand all
collapse all
unified
split
src
components
playing
NowPlaying.astro
+27
-1
src/components/playing/NowPlaying.astro
···
1
1
---
2
2
+
import { getTrack, nowPlayingSongID } from "./spotify";
2
3
4
4
+
const nowPlaying = await nowPlayingSongID();
5
5
+
6
6
+
if (nowPlaying instanceof Error) return console.error("nowPlaying", nowPlaying);
7
7
+
8
8
+
const track = nowPlaying ? await getTrack(nowPlaying) : null;
9
9
+
if (track instanceof Error) return console.error("track", track);
3
10
---
4
11
5
5
-
<section class="playing">Now Playing</section>
12
12
+
<section class="playing">
13
13
+
{
14
14
+
track ? (
15
15
+
<>
16
16
+
Now playing:
17
17
+
<img
18
18
+
src={
19
19
+
track.album.images.sort(
20
20
+
(a, b) => b.width + b.height - (a.width + a.height),
21
21
+
)[0].url
22
22
+
}
23
23
+
alt=""
24
24
+
/>
25
25
+
{track.name} by {track.artists.map((x) => x.name).join(",")}
26
26
+
</>
27
27
+
) : (
28
28
+
<>Nothing is playing :(</>
29
29
+
)
30
30
+
}
31
31
+
</section>