sort desc and use more common link fmt
This commit is contained in:
parent
a7d1fefa96
commit
9e934a9cf1
2 changed files with 4 additions and 3 deletions
1
main.go
1
main.go
|
@ -148,6 +148,7 @@ func main() {
|
||||||
|
|
||||||
for name, section := range sections {
|
for name, section := range sections {
|
||||||
// TODO: come up with sth better as one might have content there.
|
// 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)
|
os.Remove(section.File)
|
||||||
|
|
||||||
err := section.Write(section.File)
|
err := section.Write(section.File)
|
||||||
|
|
|
@ -23,7 +23,7 @@ type SectionEntry struct {
|
||||||
func (section *Section) Write(file string) error {
|
func (section *Section) Write(file string) error {
|
||||||
// sort section list
|
// sort section list
|
||||||
sort.Slice(section.List, func(i, j int) bool {
|
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
|
var buf bytes.Buffer
|
||||||
|
@ -31,8 +31,8 @@ func (section *Section) Write(file string) error {
|
||||||
for _, file := range section.List {
|
for _, file := range section.List {
|
||||||
// TODO: this could be a template
|
// TODO: this could be a template
|
||||||
entry := "\n"
|
entry := "\n"
|
||||||
entry += fmt.Sprintf("=> %s %s\n", file.Link, file.Title)
|
entry += fmt.Sprintf("=> %s %v: %s\n", file.Link, file.Date.Format("2006-01-02"), file.Title)
|
||||||
entry += fmt.Sprintf("%v - %s\n", file.Date.Format("2006-01-02"), file.Summary)
|
entry += fmt.Sprintf("%s\n", file.Summary)
|
||||||
|
|
||||||
buf.Write([]byte(entry))
|
buf.Write([]byte(entry))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue