diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2021-07-12 23:08:58 -0400 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2021-07-12 23:18:44 -0400 |
| commit | 904e37a88a6a2eab3919f7f2c40bbb2c07544a7c (patch) | |
| tree | 07ec38801bf572a2933d51d272fc4cd3ab74b61c /page/pagelist.go | |
| parent | e6d53f71c9718ecdb9fde16a924d75a71aadd2d2 (diff) | |
| download | go-website-904e37a88a6a2eab3919f7f2c40bbb2c07544a7c.tar.gz go-website-904e37a88a6a2eab3919f7f2c40bbb2c07544a7c.tar.xz | |
Add atom feed to the go website
Diffstat (limited to 'page/pagelist.go')
| -rw-r--r-- | page/pagelist.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/page/pagelist.go b/page/pagelist.go index a5cf844..f2140f9 100644 --- a/page/pagelist.go +++ b/page/pagelist.go @@ -8,6 +8,22 @@ import ( // by the date, or date reversed type PageList []*Page +// RemoveDateless returns two PageLists, the first with valid dates, +// and the second without. This is useful if you need a PageList which +// will run SortDate and SortDateReverse without issue +func (p PageList) RemoveDateless() (PageList, PageList) { + with := PageList{} + without := PageList{} + for _, p := range p { + if p.Date != nil { + with = append(with, p) + } else { + without = append(without, p) + } + } + return with, without +} + func (p PageList) SortDate() PageList { sort.Slice(p, func(i, j int) bool { return p[i].Time().After(p[j].Time()) |
