From f921e374e6e408af22de121e951b03665c16a45d Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 17 Nov 2017 14:51:55 +0100 Subject: [PATCH] Added structured data --- layout/layout.go | 15 ++++++++++++++- layout/layout.pixy | 3 ++- organization.json | 26 ++++++++++++++++++++++++++ pages/frontpage/frontpage.go | 2 +- 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 organization.json diff --git a/layout/layout.go b/layout/layout.go index 8539c313..98af3bb3 100644 --- a/layout/layout.go +++ b/layout/layout.go @@ -1,6 +1,8 @@ package fullpage import ( + "encoding/json" + "io/ioutil" "sort" "github.com/aerogo/aero" @@ -9,6 +11,17 @@ import ( "github.com/animenotifier/notify.moe/utils" ) +var organization map[string]interface{} +var organizationString string + +func init() { + // Load structured data + organizationBytes, _ := ioutil.ReadFile("organization.json") + json.Unmarshal(organizationBytes, &organization) + organizationBytes, _ = json.Marshal(organization) + organizationString = string(organizationBytes) +} + // Render layout. func Render(ctx *aero.Context, content string) string { user := utils.GetUser(ctx) @@ -33,5 +46,5 @@ func Render(ctx *aero.Context, content string) string { sort.Strings(tags) } - return components.Layout(ctx.App, ctx, user, openGraph, meta, tags, content) + return components.Layout(ctx.App, ctx, user, openGraph, meta, tags, organizationString, content) } diff --git a/layout/layout.pixy b/layout/layout.pixy index fa0dbeb6..a4487def 100644 --- a/layout/layout.pixy +++ b/layout/layout.pixy @@ -1,4 +1,4 @@ -component Layout(app *aero.Application, ctx *aero.Context, user *arn.User, openGraph *arn.OpenGraph, meta, tags []string, content string) +component Layout(app *aero.Application, ctx *aero.Context, user *arn.User, openGraph *arn.OpenGraph, meta, tags []string, organization string, content string) html(lang="en") head if openGraph != nil @@ -31,6 +31,7 @@ component Layout(app *aero.Application, ctx *aero.Context, user *arn.User, openG if user != nil #user(data-id=user.ID, data-theme=user.Settings().Theme) script(src="/scripts") + script(type="application/ld+json")!= organization component Content(content string) #content-container diff --git a/organization.json b/organization.json new file mode 100644 index 00000000..4dfa55ea --- /dev/null +++ b/organization.json @@ -0,0 +1,26 @@ +{ + "@context":"http://schema.org", + "@type":"Organization", + "name":"Anime Notifier", + "description":"Anime list, tracker, database and notifier for new anime episodes. Create your own anime list and keep track of your progress as you watch.", + "url":"https://notify.moe", + "email":"support@notify.moe", + "telephone":"", + "faxNumber":"", + "logo":"https://media.notify.moe/images/brand/512.png", + "sameAs":[ + "https://www.facebook.com/animenotifier", + "https://twitter.com/animenotifier", + "https://plus.google.com/+AnimeReleaseNotifierOfficial" + ], + "address":{ + "@type":"PostalAddress", + "addressLocality":"", + "postalCode":"", + "streetAddress":"" + }, + "founder":{ + "@type":"Person", + "name":"Eduard Urbach" + } +} \ No newline at end of file diff --git a/pages/frontpage/frontpage.go b/pages/frontpage/frontpage.go index 32d66d4b..bf83455e 100644 --- a/pages/frontpage/frontpage.go +++ b/pages/frontpage/frontpage.go @@ -8,7 +8,7 @@ import ( // Get ... func Get(ctx *aero.Context) string { - description := "Anime list and notifier for new anime episodes. Create your own anime list and keep track of your progress as you watch." + description := "Anime list, tracker, database and notifier for new anime episodes. Create your own anime list and keep track of your progress as you watch." ctx.Data = &arn.OpenGraph{ Tags: map[string]string{