package pages
import (
"bytes"
"fmt"
"slices"
"sort"
"git.akyoto.dev/go/web"
"git.akyoto.dev/web/akyoto.dev/server/app"
)
func Blog(ctx web.Context) error {
html := bytes.Buffer{}
html.WriteString(`
Blog
`)
articles := []*app.Post{}
for _, post := range app.Posts {
if !post.Published || !slices.Contains(post.Tags, "article") {
continue
}
articles = append(articles, post)
}
sort.Slice(articles, func(i, j int) bool {
return articles[i].Created > articles[j].Created
})
for _, post := range articles {
fmt.Fprintf(&html, `- %s
`, post.Slug, post.Title, post.Created, post.Created[:len("YYYY")])
}
html.WriteString(`
`)
return app.Render(ctx, "akyoto.dev", html.String())
}