use pointers to posts
1 file changed, 8 insertions(+), 8 deletions(-)
changed files
M internal/content/posts.go → internal/content/posts.go
@@ -55,8 +55,8 @@ type Collection struct { config *Config log *log.Logger - Posts []Post - Pages []Post + Posts []*Post + Pages []*Post StaticFiles []string Tags mapset.Set[string] }@@ -114,7 +114,7 @@ if err != nil { return nil, err } - if post.Date.IsZero() { + if post.Date.IsZero() && len(cs) > 1 { post.Date = cs[0].Date }@@ -175,13 +175,13 @@ for _, tag := range post.PostMatter.Taxonomies.Tags { cc.Tags.Add(strings.ToLower(tag)) } - cc.Posts = append(cc.Posts, *post) + cc.Posts = append(cc.Posts, post) } else { page, err := cc.GetPage(filename) if err != nil { return err } - cc.Pages = append(cc.Pages, *page) + cc.Pages = append(cc.Pages, page) } } else if !slices.Contains(SkipList, filename) { cc.StaticFiles = append(cc.StaticFiles, filename)@@ -193,9 +193,9 @@ } func NewContentCollection(config *Config, log *log.Logger) (*Collection, error) { cc := &Collection{ - Posts: []Post{}, + Posts: []*Post{}, Tags: mapset.NewSet[string](), - Pages: []Post{}, + Pages: []*Post{}, StaticFiles: []string{}, config: config, log: log,@@ -215,7 +215,7 @@ return cc.HandleFile(filename, d) }) - slices.SortFunc(cc.Posts, func(a, b Post) int { + slices.SortFunc(cc.Posts, func(a, b *Post) int { return b.Date.Compare(a.Date) })