feat: add artist link on lyrics page

This commit is contained in:
rramiachraf 2024-06-11 21:15:27 +01:00
parent 41d13e1edb
commit 8545cb313c
2 changed files with 16 additions and 13 deletions

View file

@ -10,13 +10,14 @@ import (
)
type Song struct {
Artist string
Title string
Image string
Lyrics string
Credits map[string]string
About string
Album AlbumPreview
Artist string
Title string
Image string
Lyrics string
Credits map[string]string
About string
Album AlbumPreview
ArtistPageURL string
}
type songResponse struct {
@ -40,6 +41,9 @@ type songResponse struct {
ProducerArtists []struct {
Name string
} `json:"producer_artists"`
PrimaryArtist struct {
URL string
} `json:"primary_artist"`
}
}
}
@ -97,6 +101,7 @@ func (s *Song) parseSongData(doc *goquery.Document) error {
s.About = songData.Description.Plain
s.Credits = make(map[string]string)
s.Album.Name = songData.Album.Name
s.ArtistPageURL = utils.TrimURL(songData.PrimaryArtist.URL)
s.Album.URL = strings.Replace(songData.Album.URL, "https://genius.com", "", -1)
s.Album.Image = ExtractImageURL(songData.Album.Image)

View file

@ -10,13 +10,11 @@ templ LyricsPage(s data.Song) {
@layout(fmt.Sprintf("%s - %s lyrics", s.Artist, s.Title)) {
<div id="container" class="trio-split">
<div id="metadata">
<img
id="album-artwork"
src={ data.ExtractImageURL(s.Image) }
alt="Song image"
/>
<img id="album-artwork" src={ data.ExtractImageURL(s.Image) } alt="Song image"/>
<div id="metadata-info">
<h2>{ s.Artist }</h2>
<a href={ templ.URL(s.ArtistPageURL) }>
<h2>{ s.Artist }</h2>
</a>
<h1>{ s.Title }</h1>
</div>
</div>