From 9e934a9cf1cecf1ad6b9e0ee0013eb1b1bb70a41 Mon Sep 17 00:00:00 2001 From: dre Date: Sun, 11 Jul 2021 23:04:52 +0800 Subject: [PATCH] sort desc and use more common link fmt --- main.go | 1 + section_list.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index b46e61e..f566000 100644 --- a/main.go +++ b/main.go @@ -148,6 +148,7 @@ func main() { for name, section := range sections { // TODO: come up with sth better as one might have content there. + fmt.Printf("clearing section %s file %s\n", name, section.File) os.Remove(section.File) err := section.Write(section.File) diff --git a/section_list.go b/section_list.go index a885cf0..ea822c4 100644 --- a/section_list.go +++ b/section_list.go @@ -23,7 +23,7 @@ type SectionEntry struct { func (section *Section) Write(file string) error { // sort section list sort.Slice(section.List, func(i, j int) bool { - return section.List[i].Date.Before(section.List[j].Date) + return section.List[i].Date.After(section.List[j].Date) }) var buf bytes.Buffer @@ -31,8 +31,8 @@ func (section *Section) Write(file string) error { for _, file := range section.List { // TODO: this could be a template entry := "\n" - entry += fmt.Sprintf("=> %s %s\n", file.Link, file.Title) - entry += fmt.Sprintf("%v - %s\n", file.Date.Format("2006-01-02"), file.Summary) + entry += fmt.Sprintf("=> %s %v: %s\n", file.Link, file.Date.Format("2006-01-02"), file.Title) + entry += fmt.Sprintf("%s\n", file.Summary) buf.Write([]byte(entry)) }