fixed up the featured artist thing
This commit is contained in:
@@ -279,7 +279,7 @@ pub fn artist_page(props: &Props) -> Html {
|
||||
<p class="text-muted">{ "No releases found on MusicBrainz." }</p>
|
||||
}
|
||||
|
||||
// Group albums by type
|
||||
// Group albums by type (primary credit only)
|
||||
{ for ["Album", "EP", "Single"].iter().map(|release_type| {
|
||||
let type_albums: Vec<_> = d.albums.iter()
|
||||
.filter(|a| a.release_type.as_deref().unwrap_or("Album") == *release_type)
|
||||
@@ -397,6 +397,56 @@ pub fn artist_page(props: &Props) -> Html {
|
||||
</div>
|
||||
}
|
||||
})}
|
||||
|
||||
// Featured releases (collapsible, pre-collapsed)
|
||||
{ for ["Album", "EP", "Single"].iter().map(|release_type| {
|
||||
let featured: Vec<_> = d.featured_albums.iter()
|
||||
.filter(|a| a.release_type.as_deref().unwrap_or("Album") == *release_type)
|
||||
.collect();
|
||||
if featured.is_empty() {
|
||||
return html! {};
|
||||
}
|
||||
html! {
|
||||
<details class="mb-2">
|
||||
<summary class="text-muted" style="cursor: pointer;">
|
||||
{ format!("Featured {}s ({})", release_type, featured.len()) }
|
||||
</summary>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 60px;"></th>
|
||||
<th>{ "Title" }</th>
|
||||
<th>{ "Date" }</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{ for featured.iter().map(|album| {
|
||||
let cover_url = format!("https://coverartarchive.org/release/{}/front-250", album.mbid);
|
||||
html! {
|
||||
<tr style="opacity: 0.6;">
|
||||
<td>
|
||||
<img class="album-art" src={cover_url}
|
||||
loading="lazy"
|
||||
onerror={Callback::from(|e: web_sys::Event| {
|
||||
if let Some(el) = e.target_dyn_into::<web_sys::HtmlElement>() {
|
||||
el.set_attribute("style", "display:none").ok();
|
||||
}
|
||||
})} />
|
||||
</td>
|
||||
<td>
|
||||
<Link<Route> to={Route::Album { mbid: album.mbid.clone() }}>
|
||||
{ &album.title }
|
||||
</Link<Route>>
|
||||
</td>
|
||||
<td class="text-muted">{ album.date.as_deref().unwrap_or("") }</td>
|
||||
</tr>
|
||||
}
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</details>
|
||||
}
|
||||
})}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user