27 lines
453 B
Go
Raw Normal View History

2016-11-19 14:54:31 +00:00
package dashboard
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
2016-11-19 14:54:31 +00:00
"github.com/animenotifier/notify.moe/components"
)
2016-12-06 03:36:31 +00:00
const maxPosts = 5
2016-11-19 14:54:31 +00:00
// Get ...
func Get(ctx *aero.Context) string {
posts, err := arn.GetPosts()
if err != nil {
2016-11-23 05:26:59 +00:00
return ctx.Error(500, "Error fetching posts", err)
}
2016-12-06 03:36:31 +00:00
arn.SortPostsLatestFirst(posts)
if len(posts) > maxPosts {
posts = posts[:maxPosts]
}
return ctx.HTML(components.Dashboard(posts))
2016-11-19 14:54:31 +00:00
}