Max length for company description in OG tags
This commit is contained in:
@ -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."
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user