1
0
Fork 0
mirror of https://github.com/avelino/awesome-go.git synced 2024-11-13 11:14:37 -05:00
This commit is contained in:
Kirill Zhuravlev 2023-02-14 19:46:53 +01:00 committed by Avelino
parent bb94bde97e
commit 994209cce9
No known key found for this signature in database
GPG key ID: B345B4D52E98180A

View file

@ -192,6 +192,8 @@ func changeLinksInIndex(html string, query *goquery.Document, objs map[string]*O
query.Find("body #content ul li ul li a").Each(func(_ int, s *goquery.Selection) {
href, hrefExists := s.Attr("href")
if !hrefExists {
// FIXME: looks like is an error. Tag `a` in our case always
// should have `href` attr.
return
}
@ -201,10 +203,15 @@ func changeLinksInIndex(html string, query *goquery.Document, objs map[string]*O
return
}
// FIXME: parse url
uri := strings.SplitAfter(href, "#")
if len(uri) >= 2 && uri[1] != "contents" {
// FIXME: use s.SetAttr
html = strings.ReplaceAll(
html, fmt.Sprintf(`href="%s"`, href), fmt.Sprintf(`href="%s"`, uri[1]))
html,
fmt.Sprintf(`href="%s"`, href),
fmt.Sprintf(`href="%s"`, uri[1]),
)
}
})