mirror of
https://github.com/avelino/awesome-go.git
synced 2024-11-13 11:14:37 -05:00
add notes
This commit is contained in:
parent
b15a1ffc03
commit
bf28343c15
1 changed files with 15 additions and 10 deletions
25
main.go
25
main.go
|
@ -166,16 +166,21 @@ func makeObjByID(selector string, s *goquery.Selection) (*Object, error) {
|
||||||
var obj Object
|
var obj Object
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
s.Find(selector).Each(func(_ int, s *goquery.Selection) {
|
s.Find(selector).Each(func(_ int, selCatHeader *goquery.Selection) {
|
||||||
desc := s.NextFiltered("p")
|
selDescr := selCatHeader.NextFiltered("p")
|
||||||
ul := s.NextFilteredUntil("ul", "h2")
|
// FIXME: bug. this would select links from all neighboring
|
||||||
|
// sub-categories until the next category. To prevent this we should
|
||||||
|
// find only first ul
|
||||||
|
ul := selCatHeader.NextFilteredUntil("ul", "h2")
|
||||||
|
|
||||||
var links []Link
|
var links []Link
|
||||||
ul.Find("li").Each(func(_ int, s *goquery.Selection) {
|
ul.Find("li").Each(func(_ int, selLi *goquery.Selection) {
|
||||||
url, _ := s.Find("a").Attr("href")
|
selLink := selLi.Find("a")
|
||||||
|
url, _ := selLink.Attr("href")
|
||||||
link := Link{
|
link := Link{
|
||||||
Title: s.Find("a").Text(),
|
Title: selLink.Text(),
|
||||||
Description: s.Text(),
|
// FIXME: Title contains only title but description contains Title + description
|
||||||
|
Description: selLi.Text(),
|
||||||
Url: url,
|
Url: url,
|
||||||
}
|
}
|
||||||
links = append(links, link)
|
links = append(links, link)
|
||||||
|
@ -186,9 +191,9 @@ func makeObjByID(selector string, s *goquery.Selection) (*Object, error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
obj = Object{
|
obj = Object{
|
||||||
Slug: slug.Generate(s.Text()),
|
Slug: slug.Generate(selCatHeader.Text()),
|
||||||
Title: s.Text(),
|
Title: selCatHeader.Text(),
|
||||||
Description: desc.Text(),
|
Description: selDescr.Text(),
|
||||||
Items: links,
|
Items: links,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue