add pub date to chapter skeleton

This commit is contained in:
lapwat
2023-10-01 22:07:38 +02:00
parent 2cbcf17cc2
commit 4521497d12
3 changed files with 12 additions and 9 deletions

View File

@@ -1,10 +1,13 @@
package book
import "time"
type link struct {
Href string `json:"url"`
Text string `json:"name"`
Href string `json:"url"`
Text string `json:"name"`
Date *time.Time `json:"date"`
}
func NewLink(href, text string) link {
return link{href, text}
func NewLink(href, text string, date *time.Time) link {
return link{href, text, date}
}

View File

@@ -370,7 +370,7 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
log.Fatal(err)
}
links = append(links, NewLink(u.String(), item.Title))
links = append(links, NewLink(u.String(), item.Title, item.PublishedParsed))
}
pathMax = "RSS"
@@ -405,7 +405,7 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
// if selector is set, we use the selector specified by the user
key = selector
pathLinks[key] = append(pathLinks[key], NewLink(href, text))
pathLinks[key] = append(pathLinks[key], NewLink(href, text, &time.Time{}))
pathCount[key] += 1
pathMax = key
@@ -419,7 +419,7 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
// we count this key if the link text is not empty
if text != "" {
pathLinks[key] = append(pathLinks[key], NewLink(href, text))
pathLinks[key] = append(pathLinks[key], NewLink(href, text, &time.Time{}))
pathCount[key] += len(text)
if pathCount[key] > pathCount[pathMax] {
@@ -449,7 +449,7 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
// include home page
if include {
l := NewLink(url.String(), home.Name())
l := NewLink(url.String(), home.Name(), &time.Time{})
links = append([]link{l}, links...)
}