feat: show artist and original artist on song detail page
Some checks failed
Deploy Fediversion / deploy (push) Failing after 1s
Some checks failed
Deploy Fediversion / deploy (push) Failing after 1s
This commit is contained in:
parent
4795d624cb
commit
dfeeb2ae81
3 changed files with 19 additions and 6 deletions
|
|
@ -54,7 +54,15 @@ def read_songs(
|
||||||
|
|
||||||
@router.get("/{slug}", response_model=SongReadWithStats)
|
@router.get("/{slug}", response_model=SongReadWithStats)
|
||||||
def read_song(slug: str, session: Session = Depends(get_session)):
|
def read_song(slug: str, session: Session = Depends(get_session)):
|
||||||
song = session.exec(select(Song).where(Song.slug == slug)).first()
|
from sqlalchemy.orm import joinedload
|
||||||
|
song = session.exec(
|
||||||
|
select(Song)
|
||||||
|
.where(Song.slug == slug)
|
||||||
|
.options(
|
||||||
|
joinedload(Song.artist),
|
||||||
|
joinedload(Song.vertical)
|
||||||
|
)
|
||||||
|
).first()
|
||||||
|
|
||||||
if not song:
|
if not song:
|
||||||
raise HTTPException(status_code=404, detail="Song not found")
|
raise HTTPException(status_code=404, detail="Song not found")
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,8 @@ class SongRead(SongBase):
|
||||||
id: int
|
id: int
|
||||||
slug: Optional[str] = None
|
slug: Optional[str] = None
|
||||||
tags: List["TagRead"] = []
|
tags: List["TagRead"] = []
|
||||||
|
artist: Optional["ArtistRead"] = None
|
||||||
|
vertical: Optional["VerticalSimple"] = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,14 +73,17 @@ export default async function SongDetailPage({ params }: { params: Promise<{ slu
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-baseline gap-3">
|
<div className="flex items-baseline gap-3">
|
||||||
<h1 className="text-3xl font-bold tracking-tight">{song.title}</h1>
|
<h1 className="text-3xl font-bold tracking-tight">{song.title}</h1>
|
||||||
{song.artist ? (
|
{song.artist && (
|
||||||
<Link href={`/artists/${song.artist.slug}`} className="text-lg text-muted-foreground font-medium hover:text-primary transition-colors">
|
<Link href={`/artists/${song.artist.slug}`} className="text-lg text-muted-foreground font-medium hover:text-primary transition-colors">
|
||||||
({song.artist.name})
|
{song.artist.name}
|
||||||
</Link>
|
</Link>
|
||||||
) : song.original_artist ? (
|
)}
|
||||||
<span className="text-lg text-muted-foreground font-medium">({song.original_artist})</span>
|
|
||||||
) : null}
|
|
||||||
</div>
|
</div>
|
||||||
|
{song.original_artist && (
|
||||||
|
<div className="text-sm text-muted-foreground mt-1">
|
||||||
|
Original Artist: <span className="font-medium text-foreground">{song.original_artist}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{song.tags && song.tags.length > 0 && (
|
{song.tags && song.tags.length > 0 && (
|
||||||
<div className="flex flex-wrap gap-2 mt-2">
|
<div className="flex flex-wrap gap-2 mt-2">
|
||||||
{song.tags.map((tag: any) => (
|
{song.tags.map((tag: any) => (
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue