mirror of
https://github.com/avelino/awesome-go.git
synced 2024-09-19 06:06:09 +00:00
change anchor to folder link
Signed-off-by: Avelino <avelinorun@gmail.com>
This commit is contained in:
parent
7e0981b926
commit
76a03b6a7f
17
make_site.go
17
make_site.go
@ -6,6 +6,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
@ -49,6 +50,7 @@ func main() {
|
|||||||
|
|
||||||
makeSiteStruct(objs)
|
makeSiteStruct(objs)
|
||||||
makeSitemap(objs)
|
makeSitemap(objs)
|
||||||
|
changeLinksInIndex(string(input), query)
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeSiteStruct(objs []Object) {
|
func makeSiteStruct(objs []Object) {
|
||||||
@ -95,3 +97,18 @@ func makeObjById(selector string, s *goquery.Selection) (obj Object) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func changeLinksInIndex(html string, query *goquery.Document) {
|
||||||
|
query.Find("body #content ul li ul li a").Each(func(_ int, s *goquery.Selection) {
|
||||||
|
|
||||||
|
href, exists := s.Attr("href")
|
||||||
|
if exists {
|
||||||
|
uri := strings.SplitAfter(href, "#")
|
||||||
|
if len(uri) >= 2 {
|
||||||
|
html = strings.ReplaceAll(html, fmt.Sprintf(`href="%s"`, href), fmt.Sprintf(`href="%s"`, uri[1]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
os.WriteFile("./tmpl/index.html", []byte(html), 0644)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user