27 lines
887 B
TypeScript
27 lines
887 B
TypeScript
export type CoverImageSize = 64 | 128 | 192 | 256 | 384 | 512 | 768 | 1024
|
|
|
|
function withCoverImageSize(uri: string, size?: CoverImageSize) {
|
|
return size ? `${uri}?size=${size}` : uri
|
|
}
|
|
|
|
export function artistCoverUrl(artistId: string, size?: CoverImageSize) {
|
|
return withCoverImageSize(`/api/artist/${artistId}/cover`, size)
|
|
}
|
|
|
|
export function albumCoverUrl(albumId: string, size?: CoverImageSize) {
|
|
return withCoverImageSize(`/api/album/${albumId}/cover`, size)
|
|
}
|
|
|
|
/** `version` is the summary's `cover`; it changes with the artwork. */
|
|
export function playlistCoverUrl(
|
|
playlistId: string,
|
|
version: string | null,
|
|
size?: CoverImageSize
|
|
) {
|
|
const params = new URLSearchParams()
|
|
if (version) params.set("v", version)
|
|
if (size) params.set("size", String(size))
|
|
const query = params.toString()
|
|
return `/api/playlist/${playlistId}/cover${query ? `?${query}` : ""}`
|
|
}
|