Skip to content

Commit

Permalink
Fix load channel
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarrough committed Apr 20, 2024
1 parent 37ab4ef commit 6d16056
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions index/v2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,34 @@
<body>
<script type="module">
import { sdk } from "https://cdn.jsdelivr.net/npm/@radio4000/sdk/+esm";

//import { createImage } from "https://cdn.jsdelivr.net/npm/@radio4000/components/r4-avatar/+esm";
/**
* @param {string} id - from cloudinary image
*/
export function createImage(id) {
const baseUrl = 'https://res.cloudinary.com/radio4000/image/upload'
const size = 250
const dimensions = `w_${size},h_${size}`
const crop = 'c_thumb,q_60'
return `${baseUrl}/${dimensions},${crop},fl_awebp/${id}.webp`
}

(async ({ slug = "" }) => {
console.log("slug", slug);
if (!slug) return;
const { data: channel } = await sdk.channels.readChannel(slug);
const { data: tracks } = await sdk.channels.readChannelTracks(slug);
const $app = document.createElement("r4-player");
$app.setAttribute("href", window.location.origin);
$app.setAttribute("title", channel.name);
$app.setAttribute("image", channel.image);
$app.setAttribute(
"tracks",
JSON.stringify(
tracks.map((track) => ({
...track,
body: track.description,
})),
),
);
$app.setAttribute("name", channel.name);
$app.setAttribute("image", createImage(channel.image));
console.log(channel, tracks)
$app.tracks = tracks.map((track) => ({
...track,
body: track.description,
}))

/* $app.setAttribute("channel", slug);
$app.setAttribute("single-channel", true); */
document.querySelector("body").append($app);
Expand Down

0 comments on commit 6d16056

Please sign in to comment.