Improved soundtrack OpenGraph tags
This commit is contained in:
parent
534372de24
commit
1609a0db75
@ -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,9 +20,20 @@ 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:description": track.MainAnime().Title.Canonical + " (" + strings.Join(descriptionTags, ", ") + ")",
|
||||||
"og:url": "https://" + ctx.App.Config.Domain + track.Link(),
|
"og:url": "https://" + ctx.App.Config.Domain + track.Link(),
|
||||||
"og:site_name": "notify.moe",
|
"og:site_name": "notify.moe",
|
||||||
"og:type": "music.song",
|
"og:type": "music.song",
|
||||||
|
Loading…
Reference in New Issue
Block a user