From e47f1d298f4c5883968b758b2775327cd9411a25 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 6 Jul 2017 20:33:46 +0200 Subject: [PATCH] Added Open Graph data to anime --- layout/layout.go | 3 ++- layout/layout.pixy | 8 +++++++- pages/anime/anime.go | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/layout/layout.go b/layout/layout.go index b963046f..4f449a21 100644 --- a/layout/layout.go +++ b/layout/layout.go @@ -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) } diff --git a/layout/layout.pixy b/layout/layout.pixy index 7cc95122..df520f62 100644 --- a/layout/layout.pixy +++ b/layout/layout.pixy @@ -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 diff --git a/pages/anime/anime.go b/pages/anime/anime.go index c61a6de9..bc34303e 100644 --- a/pages/anime/anime.go +++ b/pages/anime/anime.go @@ -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)) }