new filter method for drafts

This commit is contained in:
Niko Abeler 2022-08-22 08:06:46 +02:00
parent 709f850a73
commit e5f7417618
1 changed files with 6 additions and 3 deletions

View File

@ -66,12 +66,15 @@ func (user User) Posts() ([]*Post, error) {
}
// remove drafts
for i, post := range posts {
n := 0
for _, post := range posts {
_, meta := post.MarkdownData()
if meta.Draft {
posts = append(posts[:i], posts[i+1:]...)
if !meta.Draft {
posts[n] = post
n++
}
}
posts = posts[:n]
type PostWithDate struct {
post *Post