Tweaked cats and layout
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
@@ -38,11 +38,13 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetLatestBooks() (map[string]*Book, error) {
|
func GetLatestBooks() (map[string]*Book, error) {
|
||||||
|
fmt.Println("Fetching latest book recommendations...")
|
||||||
links := []Book{}
|
links := []Book{}
|
||||||
|
|
||||||
page := 0
|
page := 0
|
||||||
for {
|
for {
|
||||||
page++
|
page++
|
||||||
|
fmt.Println("Fetching page", page)
|
||||||
|
|
||||||
resp, err := c.Get(fmt.Sprintf("https://app.thestorygraph.com/to-read/averagemarcus?page=%d", page))
|
resp, err := c.Get(fmt.Sprintf("https://app.thestorygraph.com/to-read/averagemarcus?page=%d", page))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -100,6 +102,7 @@ func GetLatestBooks() (map[string]*Book, error) {
|
|||||||
"Business": nextByTag(links, "Business"),
|
"Business": nextByTag(links, "Business"),
|
||||||
"Technology": nextByTag(links, "Technology"),
|
"Technology": nextByTag(links, "Technology"),
|
||||||
"Sci-Fi": nextByTag(links, "Sci-Fi"),
|
"Sci-Fi": nextByTag(links, "Sci-Fi"),
|
||||||
|
"Fantasy": nextByTag(links, "Fantasy"),
|
||||||
"Comics": nextByTag(links, "Comics"),
|
"Comics": nextByTag(links, "Comics"),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@@ -192,6 +195,8 @@ func getTags(decs iter.Seq[*html.Node]) []string {
|
|||||||
tags["Technology"] = true
|
tags["Technology"] = true
|
||||||
case "science fiction":
|
case "science fiction":
|
||||||
tags["Sci-Fi"] = true
|
tags["Sci-Fi"] = true
|
||||||
|
case "fantasy":
|
||||||
|
tags["Fantasy"] = true
|
||||||
case "comics":
|
case "comics":
|
||||||
tags["Comics"] = true
|
tags["Comics"] = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(6, 1fr);
|
grid-template-columns: repeat(12, 1fr);
|
||||||
|
margin: 8px 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.category {
|
.category {
|
||||||
@@ -54,12 +55,43 @@
|
|||||||
<h1>Next Book</h1>
|
<h1>Next Book</h1>
|
||||||
<p>Suggestions for the next book to read from your Storygraph to-read pile</p>
|
<p>Suggestions for the next book to read from your Storygraph to-read pile</p>
|
||||||
</header>
|
</header>
|
||||||
<div class="container">
|
<main>
|
||||||
|
{{ $cat := "Fiction" }}
|
||||||
|
{{ $book := index . $cat }}
|
||||||
|
<div class="category" style="grid-column: span 4;">
|
||||||
|
<h3>{{ $cat }}</h3>
|
||||||
|
<a href="{{ $book.Link }}" target="_blank">
|
||||||
|
<img src="{{ $book.Image }}" alt="{{ $book.Name }} cover" style="height: 250px;" />
|
||||||
|
</a>
|
||||||
|
<a href="{{ $book.Link }}" target="_blank">{{ $book.Name }}</a>
|
||||||
|
<div class="rating">⭐ {{ $book.Rating }}</div>
|
||||||
|
</div>
|
||||||
|
{{ $cat := "Non-Fiction" }}
|
||||||
|
{{ $book := index . $cat }}
|
||||||
|
<div class="category" style="grid-column: span 4;">
|
||||||
|
<h3>{{ $cat }}</h3>
|
||||||
|
<a href="{{ $book.Link }}" target="_blank">
|
||||||
|
<img src="{{ $book.Image }}" alt="{{ $book.Name }} cover" style="height: 250px;" />
|
||||||
|
</a>
|
||||||
|
<a href="{{ $book.Link }}" target="_blank">{{ $book.Name }}</a>
|
||||||
|
<div class="rating">⭐ {{ $book.Rating }}</div>
|
||||||
|
</div>
|
||||||
|
{{ $cat := "Comics" }}
|
||||||
|
{{ $book := index . $cat }}
|
||||||
|
<div class="category" style="grid-column: span 4;">
|
||||||
|
<h3>{{ $cat }}</h3>
|
||||||
|
<a href="{{ $book.Link }}" target="_blank">
|
||||||
|
<img src="{{ $book.Image }}" alt="{{ $book.Name }} cover" style="height: 250px;" />
|
||||||
|
</a>
|
||||||
|
<a href="{{ $book.Link }}" target="_blank">{{ $book.Name }}</a>
|
||||||
|
<div class="rating">⭐ {{ $book.Rating }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<main>
|
{{ range $cat, $book := .}}
|
||||||
{{ $cat := "Fiction" }}
|
{{ if or (eq $cat "Fiction") (eq $cat "Non-Fiction") (eq $cat "Comics") }}
|
||||||
{{ $book := index . $cat }}
|
{{ continue }}
|
||||||
<div class="category" style="grid-column: span 3;">
|
{{ end }}
|
||||||
|
<div class="category">
|
||||||
<h3>{{ $cat }}</h3>
|
<h3>{{ $cat }}</h3>
|
||||||
<a href="{{ $book.Link }}" target="_blank">
|
<a href="{{ $book.Link }}" target="_blank">
|
||||||
<img src="{{ $book.Image }}" alt="{{ $book.Name }} cover" style="height: 250px;" />
|
<img src="{{ $book.Image }}" alt="{{ $book.Name }} cover" style="height: 250px;" />
|
||||||
@@ -67,34 +99,7 @@
|
|||||||
<a href="{{ $book.Link }}" target="_blank">{{ $book.Name }}</a>
|
<a href="{{ $book.Link }}" target="_blank">{{ $book.Name }}</a>
|
||||||
<div class="rating">⭐ {{ $book.Rating }}</div>
|
<div class="rating">⭐ {{ $book.Rating }}</div>
|
||||||
</div>
|
</div>
|
||||||
{{ $cat := "Non-Fiction" }}
|
{{ end }}
|
||||||
{{ $book := index . $cat }}
|
</main>
|
||||||
<div class="category" style="grid-column: span 3;">
|
|
||||||
<h3>{{ $cat }}</h3>
|
|
||||||
<a href="{{ $book.Link }}" target="_blank">
|
|
||||||
<img src="{{ $book.Image }}" alt="{{ $book.Name }} cover" style="height: 250px;" />
|
|
||||||
</a>
|
|
||||||
<a href="{{ $book.Link }}" target="_blank">{{ $book.Name }}</a>
|
|
||||||
<div class="rating">⭐ {{ $book.Rating }}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
{{ range $cat, $book := .}}
|
|
||||||
{{ if or (eq $cat "Fiction") (eq $cat "Non-Fiction") }}
|
|
||||||
{{ continue }}
|
|
||||||
{{ end }}
|
|
||||||
<div class="category">
|
|
||||||
<h3>{{ $cat }}</h3>
|
|
||||||
<a href="{{ $book.Link }}" target="_blank">
|
|
||||||
<img src="{{ $book.Image }}" alt="{{ $book.Name }} cover" style="height: 250px;" />
|
|
||||||
</a>
|
|
||||||
<a href="{{ $book.Link }}" target="_blank">{{ $book.Name }}</a>
|
|
||||||
<div class="rating">⭐ {{ $book.Rating }}</div>
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
</main>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user