27 lines
453 B
Go
Raw Normal View History

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