diff --git a/main.go b/main.go index bba53058..0ccfb9b0 100644 --- a/main.go +++ b/main.go @@ -116,34 +116,6 @@ func dropCreateDir(dir string) error { return nil } -func extractCategories(doc *goquery.Document) (map[string]Category, error) { - categories := make(map[string]Category) - doc. - Find("body #contents"). - NextFiltered("ul"). - Find("ul"). - Each(func(_ int, selUl *goquery.Selection) { - selUl. - Find("li a"). - Each(func(_ int, s *goquery.Selection) { - selector, exists := s.Attr("href") - if !exists { - return - } - - category, err := makeCategoryByID(selector, doc) - if err != nil { - return - } - - categories[selector] = *category - }) - }) - - // FIXME: handle error - return categories, nil -} - func mkdirAll(path string) error { _, err := os.Stat(path) // NOTE: directory is exists @@ -220,6 +192,34 @@ func renderSitemap(categories map[string]Category) error { return nil } +func extractCategories(doc *goquery.Document) (map[string]Category, error) { + categories := make(map[string]Category) + doc. + Find("body #contents"). + NextFiltered("ul"). + Find("ul"). + Each(func(_ int, selUl *goquery.Selection) { + selUl. + Find("li a"). + Each(func(_ int, s *goquery.Selection) { + selector, exists := s.Attr("href") + if !exists { + return + } + + category, err := makeCategoryByID(selector, doc) + if err != nil { + return + } + + categories[selector] = *category + }) + }) + + // FIXME: handle error + return categories, nil +} + func makeCategoryByID(selector string, doc *goquery.Document) (*Category, error) { var category Category var err error