diff --git a/pages/soundtrack/soundtrack.go b/pages/soundtrack/soundtrack.go index 754d3d50..b3ac9e4f 100644 --- a/pages/soundtrack/soundtrack.go +++ b/pages/soundtrack/soundtrack.go @@ -19,7 +19,21 @@ func Get(ctx aero.Context) error { return ctx.Error(http.StatusNotFound, "Track not found", err) } + relatedTracks := arn.FilterSoundTracks(func(t *arn.SoundTrack) bool { + return !t.IsDraft && len(t.Media) > 0 && t.ID != track.ID && isRelated(track.Anime(), t) + }) + customCtx := ctx.(*middleware.OpenGraphContext) customCtx.OpenGraph = getOpenGraph(track) - return ctx.HTML(components.SoundTrackPage(track, user)) + return ctx.HTML(components.SoundTrackPage(track, relatedTracks, user)) +} + +func isRelated(anime []*arn.Anime, track *arn.SoundTrack) bool { + for _, anime := range anime { + if arn.Contains(track.Tags, "anime:"+anime.ID) { + return true + } + } + + return false } diff --git a/pages/soundtrack/soundtrack.pixy b/pages/soundtrack/soundtrack.pixy index 03f87cac..3df15aae 100644 --- a/pages/soundtrack/soundtrack.pixy +++ b/pages/soundtrack/soundtrack.pixy @@ -1,4 +1,4 @@ -component SoundTrackPage(track *arn.SoundTrack, user *arn.User) +component SoundTrackPage(track *arn.SoundTrack, relatedTracks []*arn.SoundTrack, user *arn.User) SoundTrackTabs(track, user) .soundtrack-full-page @@ -37,6 +37,13 @@ component SoundTrackPage(track *arn.SoundTrack, user *arn.User) li a.soundtrack-link(href=link.URL, target="_blank")= link.Title + if len(relatedTracks) > 0 + .widget.mountable + h3.widget-title Related + .soundtracks.anime-soundtracks + each relatedTrack in relatedTracks + SoundTrackMini(relatedTrack, user) + //- TODO: This is quite ineffective, performance-wise if len(track.OsuBeatmaps()) > 0 || len(track.EtternaBeatmaps()) > 0 .widget.mountable