2024-09-23 23:09:10 +02:00
|
|
|
package blogposts
|
|
|
|
|
2024-09-24 20:57:28 +02:00
|
|
|
import (
|
|
|
|
"io/fs"
|
|
|
|
)
|
2024-09-23 23:09:10 +02:00
|
|
|
|
2024-09-24 20:57:28 +02:00
|
|
|
func NewPostsFromFS(fileSystem fs.FS) ([]Post, error) {
|
|
|
|
dir, err := fs.ReadDir(fileSystem, ".")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var posts []Post
|
|
|
|
for _, f := range dir {
|
2024-09-24 21:04:06 +02:00
|
|
|
post, err := getPost(fileSystem, f.Name())
|
2024-09-24 20:57:28 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
posts = append(posts, post)
|
|
|
|
}
|
|
|
|
return posts, nil
|
|
|
|
}
|