Max length for company description in OG tags

This commit is contained in:
Eduard Urbach 2018-03-02 00:48:44 +01:00
parent 99379a5aa4
commit 7751cd81a3

View File

@ -9,6 +9,8 @@ import (
"github.com/animenotifier/notify.moe/utils" "github.com/animenotifier/notify.moe/utils"
) )
const maxDescriptionLength = 170
// Get company. // Get company.
func Get(ctx *aero.Context) string { func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx) user := utils.GetUser(ctx)
@ -19,10 +21,15 @@ func Get(ctx *aero.Context) string {
return ctx.Error(http.StatusNotFound, "Company not found", err) return ctx.Error(http.StatusNotFound, "Company not found", err)
} }
description := company.Description
if len(description) > maxDescriptionLength {
description = description[:maxDescriptionLength-3] + "..."
}
openGraph := &arn.OpenGraph{ openGraph := &arn.OpenGraph{
Tags: map[string]string{ Tags: map[string]string{
"og:title": company.Name.English, "og:title": company.Name.English,
"og:description": company.Description,
"og:url": "https://" + ctx.App.Config.Domain + company.Link(), "og:url": "https://" + ctx.App.Config.Domain + company.Link(),
"og:site_name": "notify.moe", "og:site_name": "notify.moe",
"og:type": "article", "og:type": "article",
@ -33,8 +40,8 @@ func Get(ctx *aero.Context) string {
openGraph.Tags["og:image"] = company.Image openGraph.Tags["og:image"] = company.Image
} }
if company.Description != "" { if description != "" {
openGraph.Tags["og:description"] = company.Description openGraph.Tags["og:description"] = description
} else { } else {
openGraph.Tags["og:description"] = company.Name.English + " company information." openGraph.Tags["og:description"] = company.Name.English + " company information."
} }