From 1609a0db7503390710ef878ce5dbe970227a9226 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 4 Apr 2018 17:10:44 +0200 Subject: [PATCH] Improved soundtrack OpenGraph tags --- pages/soundtrack/soundtrack.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pages/soundtrack/soundtrack.go b/pages/soundtrack/soundtrack.go index ce989c8e..8a140230 100644 --- a/pages/soundtrack/soundtrack.go +++ b/pages/soundtrack/soundtrack.go @@ -2,6 +2,7 @@ package soundtrack import ( "net/http" + "strings" "github.com/aerogo/aero" "github.com/animenotifier/arn" @@ -19,12 +20,23 @@ func Get(ctx *aero.Context) string { return ctx.Error(http.StatusNotFound, "Track not found", err) } + descriptionTags := []string{} + + for _, tag := range track.Tags { + if strings.HasPrefix(tag, "anime:") { + continue + } + + descriptionTags = append(descriptionTags, tag) + } + openGraph := &arn.OpenGraph{ Tags: map[string]string{ - "og:title": track.Title, - "og:url": "https://" + ctx.App.Config.Domain + track.Link(), - "og:site_name": "notify.moe", - "og:type": "music.song", + "og:title": track.Title, + "og:description": track.MainAnime().Title.Canonical + " (" + strings.Join(descriptionTags, ", ") + ")", + "og:url": "https://" + ctx.App.Config.Domain + track.Link(), + "og:site_name": "notify.moe", + "og:type": "music.song", }, }