Minor change

This commit is contained in:
Eduard Urbach 2019-11-19 13:01:27 +09:00
parent b8b2fb9354
commit 99f5ae1b4f
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
2 changed files with 37 additions and 32 deletions

View File

@ -6,7 +6,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/server/middleware"
)
@ -126,34 +125,3 @@ func Get(ctx aero.Context) error {
return ctx.HTML(components.Anime(anime, animeListItem, tracks, amvs, amvAppearances, episodes, friends, friendsAnimeListItems, episodeToFriends, user))
}
func getOpenGraph(anime *arn.Anime) *arn.OpenGraph {
description := anime.Summary
if len(description) > maxDescriptionLength {
description = description[:maxDescriptionLength-3] + "..."
}
openGraph := &arn.OpenGraph{
Tags: map[string]string{
"og:title": anime.Title.Canonical,
"og:image": "https:" + anime.ImageLink("large"),
"og:url": "https://" + assets.Domain + anime.Link(),
"og:site_name": "notify.moe",
"og:description": description,
},
Meta: map[string]string{
"description": description,
"keywords": anime.Title.Canonical + ",anime",
},
}
switch anime.Type {
case "tv":
openGraph.Tags["og:type"] = "video.tv_show"
case "movie":
openGraph.Tags["og:type"] = "video.movie"
}
return openGraph
}

37
pages/anime/opengraph.go Normal file
View File

@ -0,0 +1,37 @@
package anime
import (
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/assets"
)
func getOpenGraph(anime *arn.Anime) *arn.OpenGraph {
description := anime.Summary
if len(description) > maxDescriptionLength {
description = description[:maxDescriptionLength-3] + "..."
}
openGraph := &arn.OpenGraph{
Tags: map[string]string{
"og:title": anime.Title.Canonical,
"og:image": "https:" + anime.ImageLink("large"),
"og:url": "https://" + assets.Domain + anime.Link(),
"og:site_name": "notify.moe",
"og:description": description,
},
Meta: map[string]string{
"description": description,
"keywords": anime.Title.Canonical + ",anime",
},
}
switch anime.Type {
case "tv":
openGraph.Tags["og:type"] = "video.tv_show"
case "movie":
openGraph.Tags["og:type"] = "video.movie"
}
return openGraph
}