new filter method for drafts
This commit is contained in:
parent
709f850a73
commit
e5f7417618
9
user.go
9
user.go
|
@ -66,12 +66,15 @@ func (user User) Posts() ([]*Post, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove drafts
|
// remove drafts
|
||||||
for i, post := range posts {
|
n := 0
|
||||||
|
for _, post := range posts {
|
||||||
_, meta := post.MarkdownData()
|
_, meta := post.MarkdownData()
|
||||||
if meta.Draft {
|
if !meta.Draft {
|
||||||
posts = append(posts[:i], posts[i+1:]...)
|
posts[n] = post
|
||||||
|
n++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
posts = posts[:n]
|
||||||
|
|
||||||
type PostWithDate struct {
|
type PostWithDate struct {
|
||||||
post *Post
|
post *Post
|
||||||
|
|
Loading…
Reference in New Issue