diff --git a/pkg/storygraph/client.go b/pkg/storygraph/client.go index 6ba3396..5bc4393 100644 --- a/pkg/storygraph/client.go +++ b/pkg/storygraph/client.go @@ -38,11 +38,13 @@ func init() { } func GetLatestBooks() (map[string]*Book, error) { + fmt.Println("Fetching latest book recommendations...") links := []Book{} page := 0 for { page++ + fmt.Println("Fetching page", page) resp, err := c.Get(fmt.Sprintf("https://app.thestorygraph.com/to-read/averagemarcus?page=%d", page)) if err != nil { @@ -100,6 +102,7 @@ func GetLatestBooks() (map[string]*Book, error) { "Business": nextByTag(links, "Business"), "Technology": nextByTag(links, "Technology"), "Sci-Fi": nextByTag(links, "Sci-Fi"), + "Fantasy": nextByTag(links, "Fantasy"), "Comics": nextByTag(links, "Comics"), }, nil } @@ -192,6 +195,8 @@ func getTags(decs iter.Seq[*html.Node]) []string { tags["Technology"] = true case "science fiction": tags["Sci-Fi"] = true + case "fantasy": + tags["Fantasy"] = true case "comics": tags["Comics"] = true } diff --git a/templates/index.html b/templates/index.html index 8b1e386..b59e74e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -19,7 +19,8 @@ main { display: grid; - grid-template-columns: repeat(6, 1fr); + grid-template-columns: repeat(12, 1fr); + margin: 8px 16px; } .category { @@ -54,12 +55,43 @@

Next Book

Suggestions for the next book to read from your Storygraph to-read pile

-
+
+ {{ $cat := "Fiction" }} + {{ $book := index . $cat }} +
+

{{ $cat }}

+ + {{ $book.Name }} cover + + {{ $book.Name }} +
⭐ {{ $book.Rating }}
+
+ {{ $cat := "Non-Fiction" }} + {{ $book := index . $cat }} +
+

{{ $cat }}

+ + {{ $book.Name }} cover + + {{ $book.Name }} +
⭐ {{ $book.Rating }}
+
+ {{ $cat := "Comics" }} + {{ $book := index . $cat }} +
+

{{ $cat }}

+ + {{ $book.Name }} cover + + {{ $book.Name }} +
⭐ {{ $book.Rating }}
+
-
- {{ $cat := "Fiction" }} - {{ $book := index . $cat }} -
+ {{ range $cat, $book := .}} + {{ if or (eq $cat "Fiction") (eq $cat "Non-Fiction") (eq $cat "Comics") }} + {{ continue }} + {{ end }} +

{{ $cat }}

{{ $book.Name }} cover @@ -67,34 +99,7 @@ {{ $book.Name }}
⭐ {{ $book.Rating }}
- {{ $cat := "Non-Fiction" }} - {{ $book := index . $cat }} -
-

{{ $cat }}

- - {{ $book.Name }} cover - - {{ $book.Name }} -
⭐ {{ $book.Rating }}
-
- - - {{ range $cat, $book := .}} - {{ if or (eq $cat "Fiction") (eq $cat "Non-Fiction") }} - {{ continue }} - {{ end }} -
-

{{ $cat }}

- - {{ $book.Name }} cover - - {{ $book.Name }} -
⭐ {{ $book.Rating }}
-
- {{ end }} -
- -
- + {{ end }} +