Added Open Graph data to anime

This commit is contained in:
Eduard Urbach 2017-07-06 20:33:46 +02:00
parent 4cac9f5544
commit e47f1d298f
3 changed files with 26 additions and 2 deletions

View File

@ -9,5 +9,6 @@ import (
// Render layout.
func Render(ctx *aero.Context, content string) string {
user := utils.GetUser(ctx)
return components.Layout(ctx.App, ctx, user, content)
meta, _ := ctx.Data.(map[string]string)
return components.Layout(ctx.App, ctx, user, meta, content)
}

View File

@ -1,9 +1,15 @@
component Layout(app *aero.Application, ctx *aero.Context, user *arn.User, content string)
component Layout(app *aero.Application, ctx *aero.Context, user *arn.User, meta map[string]string, content string)
html(lang="en")
head
title= app.Config.Title
meta(name="viewport", content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes")
meta(name="theme-color", content=app.Config.Manifest.ThemeColor)
if meta != nil
for property, value := range meta
meta(name=property, value=value)
link(rel="chrome-webstore-item", href="https://chrome.google.com/webstore/detail/hajchfikckiofgilinkpifobdbiajfch")
link(rel="manifest", href="/manifest.json")
body

View File

@ -39,5 +39,22 @@ func Get(ctx *aero.Context) string {
}
}
// Open Graph
openGraph := map[string]string{
"og:title": anime.Title.Canonical,
"og:image": anime.Image.Large,
"og:url": "https://" + ctx.App.Config.Domain + anime.Link(),
"og:site_name": "notify.moe",
}
switch anime.Type {
case "tv":
openGraph["og:type"] = "video.tv_show"
case "movie":
openGraph["og:type"] = "video.movie"
}
ctx.Data = openGraph
return ctx.HTML(components.Anime(anime, tracks, user, episodesReversed))
}