Added structured data

This commit is contained in:
Eduard Urbach 2017-11-17 14:51:55 +01:00
parent 09c47b7c6d
commit f921e374e6
4 changed files with 43 additions and 3 deletions

View File

@ -1,6 +1,8 @@
package fullpage package fullpage
import ( import (
"encoding/json"
"io/ioutil"
"sort" "sort"
"github.com/aerogo/aero" "github.com/aerogo/aero"
@ -9,6 +11,17 @@ import (
"github.com/animenotifier/notify.moe/utils" "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. // Render layout.
func Render(ctx *aero.Context, content string) string { func Render(ctx *aero.Context, content string) string {
user := utils.GetUser(ctx) user := utils.GetUser(ctx)
@ -33,5 +46,5 @@ func Render(ctx *aero.Context, content string) string {
sort.Strings(tags) 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)
} }

View File

@ -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") html(lang="en")
head head
if openGraph != nil if openGraph != nil
@ -31,6 +31,7 @@ component Layout(app *aero.Application, ctx *aero.Context, user *arn.User, openG
if user != nil if user != nil
#user(data-id=user.ID, data-theme=user.Settings().Theme) #user(data-id=user.ID, data-theme=user.Settings().Theme)
script(src="/scripts") script(src="/scripts")
script(type="application/ld+json")!= organization
component Content(content string) component Content(content string)
#content-container #content-container

26
organization.json Normal file
View File

@ -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"
}
}

View File

@ -8,7 +8,7 @@ import (
// Get ... // Get ...
func Get(ctx *aero.Context) string { 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{ ctx.Data = &arn.OpenGraph{
Tags: map[string]string{ Tags: map[string]string{