Improved soundtrack OpenGraph tags

This commit is contained in:
Eduard Urbach 2018-04-04 17:10:44 +02:00
parent 534372de24
commit 1609a0db75

View File

@ -2,6 +2,7 @@ package soundtrack
import ( import (
"net/http" "net/http"
"strings"
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
@ -19,12 +20,23 @@ func Get(ctx *aero.Context) string {
return ctx.Error(http.StatusNotFound, "Track not found", err) 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{ openGraph := &arn.OpenGraph{
Tags: map[string]string{ Tags: map[string]string{
"og:title": track.Title, "og:title": track.Title,
"og:url": "https://" + ctx.App.Config.Domain + track.Link(), "og:description": track.MainAnime().Title.Canonical + " (" + strings.Join(descriptionTags, ", ") + ")",
"og:site_name": "notify.moe", "og:url": "https://" + ctx.App.Config.Domain + track.Link(),
"og:type": "music.song", "og:site_name": "notify.moe",
"og:type": "music.song",
}, },
} }